well turns out there is problems
this is mine
when i enter the values 60=leng 48=wid 1=oak 4=drawersCode:// File: lab3_141.java // Jeremy Otis // 08 import java.io.* ; public class lab3_141 { public static void main(String[] args) { double area; double wood; double width; double length; double drawer; double price = 200; System.out.print("Enter the length of the desk : "); length=MyInput.readInt(); System.out.print("Enter the width of the desk : "); width=MyInput.readInt(); area = (length * width); if (area > 1000) price += 75; if (area > 2000) price += 125; System.out.println("Wood Selection!"); System.out.println("1. Oak - $100"); System.out.println("2. Mahogany - $150"); System.out.println("3. Pine - $0"); System.out.print("Enter the type of wood: "); wood = MyInput.readInt(); if (wood == 1) price += 100; if (wood == 2) price += 150; if (wood == 3) price += 0; System.out.print("Enter the number of drawers: "); drawer= MyInput.readInt(); price += (drawer * 30); System.out.println("The cost of your desk is: $" + price ); } }
i get the answer 620
However on your program (with slight modifications)
Using the same values i get 545 which is correct.Code:import java.io.* ; public class labredo { public static void main(String[] args) { int price = 200; int width; int length; int surface; int wood; int drawers; System.out.print("Enter table surface's width (inches): "); width = MyInput.readInt(); System.out.print("Enter table surface's length (inches): "); length = MyInput.readInt(); surface = width * length; if((surface > 1000) && (surface < 2000)) { price += 75; } if(surface > 2000) { price += 125; } System.out.println("Wood Selection!"); System.out.println("1. Oak - $100"); System.out.println("2. Mahogany - $150"); System.out.println("3. Pine - $0"); System.out.print("Which type of wood: "); wood = MyInput.readInt(); if (wood == 1) { price += 100; }if (wood == 2) { price += 150; }if (wood == 3) { price += 0; } System.out.print("How many drawers would you like - $30/drawer:$ drawers = MyInput.readInt(); price += (drawers * 30); System.out.println("Your new desk is going to cost: $" + price); } }
What math am i doing wrong?




Reply With Quote