Question

In: Computer Science

JAVA Write code which takes three decimal inputs from the user, creates a circle with a...

JAVA

Write code which takes three decimal inputs from the user, creates a circle with a radius equal to the first input and a rectangle with length and width equal to the second and third input respectively, then prints both of these shapes.

Sample run:

Type a radius:
3.7
Type a length:
4.9
Type a width:
8.6
circle with radius 3.7
rectangle with length 4.9, width 8.6

Solutions

Expert Solution

import java.util.*;

public class Sample{

public static void main(String args[]){

double radius,length,width;

Scanner input=new Scanner(System.in);

System.out.println("Type a radius:");

radius=input.nextDouble();

System.out.println("Type a length:");

length=input.nextDouble();

System.out.println("Type a width:");

width=input.nextDouble();

System.out.println("circle with radius "+radius);

System.out.println("rectangle with length "+length+", width "+width);

}

}

import java.util.*;

public class Sample{

public static void main(String args[]){

double radius,length,width;

Scanner input=new Scanner(System.in);

System.out.println("Type a radius:");

radius=input.nextDouble();

System.out.println("Type a length:");

length=input.nextDouble();

System.out.println("Type a width:");

width=input.nextDouble();

String Circle="circle with radius "+radius;

String Rectangle="rectangle with length "+length+", width "+width;

System.out.println(Circle);

System.out.println(Rectangle);

}

}


Related Solutions

IN JAVA: Write a simple program that takes 5 inputs from the user and save them...
IN JAVA: Write a simple program that takes 5 inputs from the user and save them into a Text File. The inputs are Student Name, Student Address and student Date of Birth. Also write a simple program that reads and display the input from the first program text file.
write a java program that takes three numbers from the user and print the greatest number...
write a java program that takes three numbers from the user and print the greatest number (using if-statement). sample output: input the first number:35 input the second number:28 input the third number:87 the greatest number:87
Write a program, Lab02_Q4.py, that inputs a string from the user, and creates a new string...
Write a program, Lab02_Q4.py, that inputs a string from the user, and creates a new string that deletes each non-alphanumeric character in the original string. You should solve this problem in 2 ways, first use a for loop that iterates through each character in the string, the second should use a while loop that iterates through a range. Keep spaces in the new string also. Hint: You can invoke the isalnum() function on a character, and it will return True...
Java Code: Write an application that takes in user input. (Name, Age, and Salary) ------ Write...
Java Code: Write an application that takes in user input. (Name, Age, and Salary) ------ Write an application that includes a constructor, user input, and operators.
Write c code program for the following Write a function, circle, which takes the radius of...
Write c code program for the following Write a function, circle, which takes the radius of a circle from the main function and assign the area of the circle to the variable, area, and the perimeter of the circle to the variable, perimeter. Hint: The function should have three variables as input. Since the contents of the variables are to be modified by a function, it is necessary to use pointers. Please type out the full usable program. Thank you.
in. java Write a program that reads a string from the user, and creates another string...
in. java Write a program that reads a string from the user, and creates another string with the letters from in reversed order. You should do this using string concatenation and loops. Do not use any method from Java that does the work for you. The reverse string must be built. Do not just print the letters in reversed order. Instead, concatenate them in a string. --- Sample run: This program will create a string with letters in reversed order....
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax.   answer within 25 min plzzz
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax. I need this answer ASAP PLZ.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT