Assignment #27: Variables Only Hold Values
Code
/// Name: Kiran O'Farrell
/// Period: 7
/// Program name: Variables Only Hold Values
/// File Name: ValuesOnly.java
/// Date Finished: 9/23/15
import java.util.Scanner;
public class ValuesOnly {
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
// BROKEN
double price = 0, salesTax, total;
salesTax = price * 0.0825;
total = price + salesTax;
System.out.print( "How much is the purchase price? " );
price = keyboard.nextDouble();
System.out.println( "Item price:\t" + price );
System.out.println( "Sales tax:\t" + salesTax );
System.out.println( "Total cost:\t" + total );
}
}
Picture of the output