Welcome to Assignmentgeek Q&A, where you can ask questions and receive answers from experts and other members of the community. Back to Homepage

Java script help

0 votes
Request that the user enter the radius of a circle from the keyboard and store the value entered in the double variable, radius.
asked Jul 12, 2017 in Programming by Sophia

1 Answer

0 votes
import java.util.Scanner;

public class Test {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
System.out.println("Enter the radius of a circle: ");
double radius;
do {
double temp = s.nextDouble();
radius = (temp < 0) ? -1 : temp;
if (radius == -1)
System.out.println("Enter the positive value");
} while (radius == -1);
}
}
answered Jul 12, 2017 by admin (2,270 points)
...