Answer to Question #312070 in Java | JSP | JSF for aqilah

Question #312070

Write an application for Furniture Company Sdn Bhd, the program determines the total price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany and prompt the user to enter the number of a table. The output is the name of the wood chosen as well as the price of the table. Pine table cost RM100, oak tables cost RM225, and mahogany tables cost RM310. If the user enters an invalid wood code, set the price to 0. 


Furniture Company Sdn Bhd also gives an appreciation for the member card holder with 6% off from the total price. The above price is exclude government tax RM 5.60.

Save the file as Furniture.java.        

 




1
Expert's answer
2022-03-17T13:56:06-0400


import java.util.*;


class Furniture {
	static double DeterminePriceOfTable(int wood) {
		if (wood == 1)
			return 100;
		if (wood == 2)
			return 225;
		if (wood == 3)
			return 310;
		return 0;
	}


	public static void main(String[] args) {
		Scanner keyboard = new Scanner(System.in);


		System.out.println("Please select a wood:");
		System.out.println("1. Pine");
		System.out.println("2. Oak");
		System.out.println("3. Mahogany");
		System.out.print("Your choice: ");
		int choice = keyboard.nextInt();
		int cardHolder = -1;
		System.out.println();
		if (choice >= 1 && choice <= 3) {
			System.out.print("The member card holder with 6%? 1 - yes, 2 -no: ");
			cardHolder = keyboard.nextInt();
			if (choice == 1)
				System.out.println("Wood: Pine");
			else if (choice == 2)
				System.out.println("Wood: Oak");
			else if (choice == 3)
				System.out.println("Wood: Mahogany");
		} else
			System.out.println("Invalid wood code");


		double tablePrice = DeterminePriceOfTable(choice);
		if (cardHolder == 1) {
			tablePrice -= tablePrice * 0.06;
		}
		tablePrice-= 5.6;
		System.out.println("Tovernment tax RM 5.60");
		System.out.println("Price of the table: RM " + tablePrice);


		keyboard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS