import java.util.*;

public class DiscountBolts 
{


	public static void main(String[] args) 
	{
		Scanner keyboard = new Scanner(System.in);
		double bolts, nuts, washers;
		double total;

		System.out.println("Enter number of bolts: ");
		bolts = keyboard.nextDouble();
		System.out.println("Enter number of nuts: ");
		nuts = keyboard.nextDouble();
		System.out.println("Enter number of washers: ");
		washers = keyboard.nextDouble();

		total = (bolts * 0.05) + (nuts * 0.03) + (washers * 0.01);


		if (bolts > nuts)
		{
			System.out.println("Check the order: too few nuts");
		}
		if (bolts >= washers)
		{
			System.out.println("Check the order: too few washers");		
		}
		{
		if (nuts > bolts && washers*2 > bolts)
		{
			System.out.println("Order is CORRECT");
			System.out.printf("Order total is: $%.2f \n ", total);
		}
		{
		}
		}
	    }






}

A correct order must have at least as many nuts as bolts, and at least twice as many washers as bolts, otherwise the order has an error.

How would i do my if statement so it will read that it has twice as many washers??

i tryed washers * 2 but it didnt work

A correct order must have at least as many nuts as bolts, and at least twice as many washers as bolts, otherwise the order has an error.

Well, you have done the opposite of what you should do.(line 32) According to the given question, number_of_washers should be greater than or equal to twice_the_number_of_bolts.

its still not working my program goes blank, i put :

if(nuts > bolts && washers >= 2*bolts)

I think the right way to achieve this is :

import java.util.*;
 
public class DiscountBolts 
{
 
 
	public static void main(String[] args) 
	{
		Scanner keyboard = new Scanner(System.in);
		double bolts, nuts, washers;
		double total;
 
		System.out.println("Enter number of bolts: ");
		bolts = keyboard.nextDouble();
		System.out.println("Enter number of nuts: ");
		nuts = keyboard.nextDouble();
		System.out.println("Enter number of washers: ");
		washers = keyboard.nextDouble();
 
		total = (bolts * 0.05) + (nuts * 0.03) + (washers * 0.01);

if (nuts<bolts)//at least as many nuts as bolts
{
    System.out.println("Check the order: too few nuts");
}
if (washers<(2*bolts))//at least twice as many washers as bolts
{
    System.out.println("Check the order: too few washers");		
}
         if (nuts >= bolts && washers>= (2*bolts) )//as many nuts as bolts and twice as many washers as bolts
		{
			System.out.println("Order is CORRECT");
			System.out.printf("Order total is: $%.2f \n ", total);
		}
}//end method main

}//end class

Thank you.

Please mark as solved below if this worked well for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.