Write a program to calculate the rent of a user defined space and dimensions. Th
ID: 3776832 • Letter: W
Question
Write a program to calculate the rent of a user defined space and dimensions. The total rent should allow the calculation of three primary shapes(squares, rectangles, & circles). First the shape must be defined, then the dimensions will be entered and then the rent is based on the area times the cost per square foot(20 dollars per square foot). Use labels & prompts.
MIPS Usins MARS
Write a program to calculate the rent of a user defined space and dimensions. The total rent should allow the calculation of three primary shapes (squares, rectangles and circles). First the shape must be defined, then the dimensions will be entered and then the rent is based on the area times the cost per square foot (20 dollars per square foot). Use labels and prompts!Explanation / Answer
import java.util.Scanner;
public class HelloWorld {
public static void main(String []args)
{
Scanner in = new Scanner(System.in);
int input,input1;
System.out.println("choose the shape ");
System.out.println("1. Square ");
System.out.println("2. Rectangle ");
System.out.println("3. Circle ");
System.out.println("4. Quit ");
System.out.println("Enter your choice ");
int choice = in.nextInt();
switch(choice) {
case 1 :
System.out.println("Enter the side (as a FOOT): ");
input = in.nextInt();
System.out.println("The cost per square foot is " + (input*input*20));
break;
case 2 :
System.out.println("Enter the length: ");
input = in.nextInt();
System.out.println("Enter the width: ");
input1 = in.nextInt();
System.out.println("The cost per square foot is " + (input*input1*20));
break;
case 3 :
System.out.println("Enter the radius: ");
input = in.nextInt();
System.out.println("The cost per square foot is " + (3.14*input*input*20));
break;
default :
System.out.println("Invalid input ");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.