Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sorry if you have problem with this post. This problem had to be posted this way

ID: 3622202 • Letter: S

Question

Sorry if you have problem with this post. This problem had to be posted this way because the second part can not be isolated from the first part (1A & 1B):

1A)
Write an application for a furniture company; the program determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name for the wood chosen as well as the price of the table. Pine tables cost $100, oak tables cost $225, and mahogany tables cost $310. If the user enters an invalid wood code, set the price to 0. Save your file as Furniture.java.
1B)
Add a prompt to the above application to ask the user to specify a (1) large or (2) small table. Add $35 to the price of any large table. Save your file as Furniture2.java.

Explanation / Answer

public class Furniture
{
public static void main(String[] args)
{
// keyboard input
Scanner kb = new Scanner(System.in);

// ask for type of wood
System.out.println("Choose the type of wood: ");
System.out.println(" 1 - pine");
System.out.println(" 2 - oak");
System.out.println(" 3 - mahogany");

int type = kb.nextInt();

// switch type of wood to price
double price;
String wood;

switch(type)
{
case 1: price = 100.0; wood = "pine"; break;
case 2: price = 225.0; wood = "oak"; break;
case 3: price = 310.0; wood = "mahogany"; break;
default: price = 0.0; wood = "unknown"; break;
}

System.out.println("$"+String.format("%.2f", price)+" for "+wood);
}
}

public class Furniture2
{
public static void main(String[] args)
{
// keyboard input
Scanner kb = new Scanner(System.in);

// ask for type of wood
System.out.println("Do you want pine(1), oak(2), or mahogany(3)? ");

int type = kb.nextInt();

// switch type of wood to price
double price;
String wood;

switch(type)
{
case 1: price = 100.0; wood = "pine"; break;
case 2: price = 225.0; wood = "oak"; break;
case 3: price = 310.0; wood = "mahogany"; break;
default: price = 0.0; wood = "unknown"; break;
}

// check for small/large table
System.out.print("Do you want a small (1) or large(2) table? ");

int table = kb.nextInt();

if(table == 2)
{
price += 35;
}


System.out.println("$"+String.format("%.2f", price)+" for "+wood);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote