64 630
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #58790 in Java | JSP | JSF for Lekorius Wallace

Question #58790
Design a program that asks the user to enter a floating-point number (either positive or negative). The program repeats while the user enters ‘y’ to continue. The program allows a user to enter either a lowercase or uppercase character. Use the ceil use the ( ), floor ( ), and abs ( ) methods to determine the smallest whole number that is greater than or equal to the number entered, the largest whole number that is less than or equal to the number entered, and the absolute value of the number given, respectively. Use the toLowercase ( ) method to change a given character value to lowercase if the value is an uppercase value.
Expert's answer
import java.util.Scanner;

public class FloatData {

public static void main(String[] args) {

Scanner reader = new Scanner(System.in);

while (true) {
System.out.println("Enter a floating-point number: ");
float f = reader.nextFloat();
System.out.println(Math.ceil(f));
System.out.println(Math.floor(f));
System.out.println(Math.abs(f));
String s = "";
System.out.println("Would you like to repeat? Press 'y' ");
while (!(s = reader.next()).toLowerCase().equals("y"));
}

}

}

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