At the State Fair Pie Eating Contest all contestants in the heavyweight
division must weigh within 30 pounds of 250 pounds. Write a program that asks for a
contestant's weight and then says if the contestant is allowed in the contest.
1
Expert's answer
2012-10-25T10:35:17-0400
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.println("Enter your weight in pounds, please: ");
String temp = console.next();
int weight = Integer.parseInt(temp);
if (weight >= 30 && weight <= 250) {
System.out.println("You're allowed in the contest");
} else
System.out.println("You're NOT allowed in the contest");
Comments
Leave a comment