64 665
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #61602 in Java | JSP | JSF for Bill DeShields

Question #61602
Write a program that prompts the user for an even multiple of 29 that is under 50. Respond to the user's input as appropriate.
Expert's answer

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s;
int i;

System.out.println("Please enter the number. To close the program type \"exit\"");

while (true) {
s = reader.readLine();
if (s.equals("exit")) break;

i = Integer.parseInt(s);
if (i % 29 == 0 && i % 2 == 0 && i < 50)
System.out.println(i + " is a correct number");
else
System.out.println(i + " is an incorrect number");
}

reader.close();
}
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions