1 Attachment(s)
New to java a little confused.
****Problem was resolved****
Hi I am new to this so bare with me. I am taking an online course for java programming we have to make a program that will calculate whether an online purchase is eligable for free shipping or not. Here is what I have when I try to run it it has a problem with "itemPrice = keyboard.nextInt();" Is there something else I should use? It wont build it if I dont have something in there for the itemPrice integer.
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package lab3;
import java.util.Scanner;
/**
*
* @author Jonathon
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int itemPrice;
double itemShip, itemTotal;
System.out.println("Enter Price:");
itemPrice = keyboard.nextInt();
if (itemPrice >= 99.99){
itemShip = 0;
System.out.println("You are eligable for free shipping!");
itemTotal = itemPrice;
System.out.println("Your total is:" + itemTotal);
}else
itemShip = 8.95;
itemTotal = itemPrice + itemShip;
System.out.println("Your total is:" + itemTotal);
}
}