I need J ava-like pseudocode for this program, please. import java.util.Scanner;
ID: 3583136 • Letter: I
Question
I need Java-like pseudocode for this program, please.
import java.util.Scanner;
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);
}
}
Explanation / Answer
/* The pseudo code for option available for wooden type then read type from user using Scanner class and print the wooden type with his value */
main ()
print”choose the type of wood”
print”press 1 for pine”
print”press 2 for oak”
print”press 3 for mahogany”
type<--read value from user using keyboard
price<--0.0
wood<--null
switch(type)
case 1: price <--100.0 wood <--pine
case 2 price <--225.0 wood <--oak
case 3 price <--310.0 wood <-- mahogany
default price <--0.0 wood <--unknown
Output type of wood along with price with $ and string format
end main
/* The pseudo code for option available for wooden type then read type from user using Scanner class and also read the size of selected wooden type from user then print the wooden type with his value */
main ()
print”choose the type of wood”
print”press 1 for pine”
print”press 2 for oak”
print”press 3 for mahogany”
type<--read value from user using keyboard
price<--0.0
wood<--null
switch(type)
case 1: price <--100.0 wood <--pine
case 2 price <--225.0 wood <--oak
case 3 price <--310.0 wood <-- mahogany
default price <--0.0 wood <--unknown
print”press 1 for small”
print”press 2 for large”
table <--read value from user using keyboard
if (table=2)
price<--price+3
Output type of wood along with price with $ and string format
end main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.