Java
Write a program that prompt the user to enter a decimal number representing the radius of a circle. If the number is greater or equal to zero, the program displays the area of the circle. Otherwise, the program displays “negative input”
CircleAreaDemo.java
import java.util.Scanner;
public class CircleAreaDemo {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the radius of a circle: ");
double radius = scan.nextDouble();
if(radius>=0) {
double area = Math.PI * radius * radius;
System.out.println("Circle Area: "+area);
} else {
System.out.println("negative input");
}
}
}
Output:
Enter the radius of a circle:
8
Circle Area: 201.06192982974676
Enter the radius of a circle:
-1
negative input
Java Write a program that prompt the user to enter a decimal number representing the radius...
Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...
java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...
In Java please: Write a program that will prompt the user to enter GPA values one per line, stopping when the user enters a negative Input: value. Print the following on separate lines: . The number of vaild GPAs entered » The sum of the GPAs 4.0 3.7 2.9 3.5 -1 The average GPA
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
Please write in JAVA ONLY Please use a dialog box to prompt the user to enter the radius for a circle (radius should be a double). Then, use a Message Box to display the Radius, Area and Circumference of the circle with that Radius. You will use the Math class constant Math.PI to calculate the Area and Circumference.
Write a program that asks the user to enter number, and displays all the numbers that are multiples of 2 and 5 smaller than or equal to the number entered by the user. Hint: A number n is a multiple of 2 if the remainder of the division of n by 2 is equal to zero. Your program should have an output similar to the following: Please enter a number: 50 The multiples of 2 and 5 less than or...
Write a Java program to meet the following requirements: 1. Prompt the user to enter three strings by using nextLine(). Space can be part of the string). ( Note: your program requires using loop: for-loop, while-loop or do-while-loop to get the input String ) 2. Write a method with an input variable (string type).The method should return the number of lowercase letters of the input variable. 3. Get the number of the lowercase letters for each user input string by...
Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...
in java 3) Sum. Write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect.
Write a java program to prompt the user to enter three doubles and compute the sum and product. Print "The sum is 999 and the product is 999.", where 999 is replaced with the user sum and product.