You have several pictures of different sizes that you would like to frame.A local picture framing store offers two types of frames—regular andfancy. The frames are available in white and can be ordered in any colorthe customer desires. Suppose that each frame is 1 inch wide. The costof coloring the frame is $0.10 per inch. The cost of a regular frame is$0.15 per inch and the cost of a fancy frame is $0.25 per inch. The costof putting a cardboard paper behind the picture is $0.02 per square inchand the cost of putting glass on top of the picture is $0.07 per square inch. The customer can also choose to put crowns on the corners,which costs $0.35 per crown. Write a program that prompts the userto input the following information and then output the cost of framing the picture:a. The length and width, in inches, of the picture.b. The type of the frame.c. Customer's choice of color to color the frame.d. If the user wants to add the crowns, then the number of crowns.

Respuesta :

Debel

Answer:

written in java

Note :  Package name was excluded

 

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       //declared 8 uninitialised variable  

       String input;

       double cost, colorC, frameC, paperC, glassC, crownC;

       char crowns;

       int type, color, crown, length, width, area, perimeter;

       

       //creating an instance of the Scanner class to accept value from user

       Scanner scanner = new Scanner(System.in);

       System.out.print("Enter length of frame: ");

       length = scanner.nextInt();

       System.out.print("Enter width of frame: ");

       width = scanner.nextInt();

       System.out.print("Do you want a fancy frame or a regular frame\nEnter 1 for fancy, 2 for regular: ");

       type = scanner.nextInt();

       if (type == 1) {

           frameC = 0.25;

       } else {

           frameC = 0.15;

       }

       System.out.print("Do you want a white frame or a colored frame\nEnter 1 for white, 2 for colored: ");

       color = scanner.nextInt();

       if (color == 2) {

           colorC = .10;

       } else{

           colorC = 0;

       }

       System.out.print("Do you want crowns \nEnter y for yes, n for no ");

       input = scanner.next();

       crowns = input.charAt(0);

       if (crowns == 'y' || crowns == 'Y') {

           System.out.print("How many crowns?");

           crown = scanner.nextInt();

       } else

           crown = 0;

       if (crown > 0)

           crownC = crown * .35;

       else

           crownC = 0;

       area = length * width;

       perimeter = length * 2 + width * 2;

       paperC = area * .02;

       glassC = area * .07;

       cost = glassC + paperC + crownC + colorC * perimeter + frameC * perimeter;

       System.out.println("The cost of your frame is: $" + cost);

   }

}