Answer to Question #17130 in Java | JSP | JSF for Sayed Abdullah Almousawi

Question #17130
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");




}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS