You are on page 1of 1

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package IfElseLabs2;
import java.util.Scanner;
/**
*
* @author Guest
*/
public class NutsAndBolts {
public static void main(String[] args) {
Scanner reader = new Scanner (System.in);
System.out.print("Enter number of bolts: ");
int bolts = reader.nextInt();
System.out.print("Enter number of nuts: ");
int nuts = reader.nextInt();
System.out.print("Enter number of washers: ");
int washers = reader.nextInt();
if (washers >= bolts * 2 && nuts >= bolts ) {
System.out.println("Order is OK");
}
else if ( (nuts < bolts) && (bolts * 2 == washers) ) {
System.out.println("Too few nuts");
}
else if ( (washers < 2 * bolts)
System.out.println("Too few
}
else if ( (washers < 2 * bolts)
System.out.println("Too few

&& (nuts == bolts)){


washers");
&& (nuts < bolts) ){
nuts and too few washers");

}
double cost = 0.05 * bolts + 0.03 * nuts + 0.01 * washers ;
System.out.println("Total cost is: $" + cost);
}
}

You might also like