Can Someone Help Me With This Simple Java Program?

we have to make a program where you can put in how many balloons you want and you get a discount based on how many you buy. i think ive gotten most of the work done but i need a little help perfecting it. can someone please look at it and tell me what to change/add? thank you in advance.
import java.util.Scanner;
public class widgetsales {
public static void main (String[] args) {
double price;
int order;
float total;
System.out.print(“How many balloons will you be buying?”);
if (order < 11) {
price = 1.00; }
if ((order 10)) {
price = 0.90; }
if ((order 25)) {
price = 0.85; }
if (order > 49) {
price = 0.80; }
total = order * price;
System.out.println(order +” balloons have been ordered”);
System.out.println(“Price per balloon is “+ price);
System.out.println(“Your total price is “+ total);
}
}

Both comments and pings are currently closed.

One Response to “Can Someone Help Me With This Simple Java Program?”

  1. Andrew K says:

    i would do it like this
    import java.util.Scanner;
    public class widgetsales {
    public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    double price = 1;
    try{
    System.out.println(“How many baloons would you like: “);
    double order = input.nextDouble();
    if (order < 11){ //0-9 price = price * order; } else if ((order < 26) && (order > 10)) {
    //25-9
    price = price * order;
    price = price * .9;
    }
    else if ((order < 50) && (order > 25)) {
    //49-26
    price = price * order;
    price = price * .8;
    }
    else {
    //50 and up
    price = price * order;
    price= price * .7;
    }
    System.out.println(“cost is: “+price);
    System.out.println(“Ballons Ordered is: “+ order);
    }
    catch (Exception e) {
    // if you input a string or other exceptions
    System.out.println(“Invalid Input: “);
    }
    }
    }
    Of course if you want a more complex code (like classes, execption, methods, loops) just let me know
    ill make it more complex
    Any questions let me know

Powered by WordPress | Designed by: free css template | Thanks to hostgator coupon and web hosting reviews