Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//Folder/Project Name: Project 2 //Programmer Name: Example //Date: 3.5.2012 //C

ID: 3640462 • Letter: #

Question

//Folder/Project Name: Project 2
//Programmer Name: Example
//Date: 3.5.2012
//Class Name: ScannerApplication
/* Project Description: This is the skeleton for an application
*/

import java.util.Scanner;

import javax.swing.JOptionPane;

public class ScannerApplication
{

//This method is the first method executed in an application
//This method will prompt user for input, retrieve data using Scanner object,
//and display the input to the screen
public static void main(String[] args)
{
//Declare local variables / objects
string firstNameString;
double number1double;
double number2double;
double number3double;
double subTotal;
float salesTax = .0925F;
float salesTaxFloat;
double total;

Scanner inputScanner = new Scanner(System.in);

//Retrieve input from the keyboard and assign to variables
//System.out.print("Enter your first name: ");
//firstNameString = inputScanner.next();
firstNameString= JOptionPane.showInputDialog("Please enter your first name:");

System.out.print("Please enter your first name: ");
firstNameString= inputScanner.next();

System.out.print("Enter item 1 price: ");
number1double= inputScanner.next();

System.out.print("Enter item 2 price: ");
number2double = inputScanner.nextInt();

System.out.print("Enter item 3 price: ");
number3double = inputScanner.nextFloat();

System.out.print("Enter the salestax: ");
salesTaxFloat = inputScanner.nextFloat();

//Declare constant
final float SALES_TAXFloat = .0925F;


//Do some arithmetic
subTotal = number1double + number2double + number3double;
System.out.println("subtotal = " + subTotal + " ");
salesTaxFloat = (float) (subTotal * .0925F);
System.out.println("salesTax = " + salesTaxFloat + " ");

//display the input obtained
System.out.print(" your name is: " + firstNameString);
System.out.print(" your subtotal is: " + number1double + number2double + number3double);
System.out.print(" your salestax is: " + salesTaxFloat);
System.out.print(" your total is: " + subTotal + salesTaxFloat);

}//End of main method

}//End of ScannerApplication


*comment* Hi, I have a problem with running this program I created with eclipse. Can you help me out?

Explanation / Answer

The corrected code is below.....:)..

//Folder/Project Name: Project 2
//Programmer Name: Example
//Date: 3.5.2012
//Class Name: ScannerApplication
/* Project Description: This is the skeleton for an application
*/

import java.util.Scanner;
public class ScannerApplication
{

    //This method is the first method executed in an application
//This method will prompt user for input, retrieve data using Scanner object,
//and display the input to the screen
    public static void main(String[] args)
    {
//Declare local variables / objects
        String firstNameString;
        double number1double;
        double number2double;
        double number3double;
        double subTotal;
        float salesTax = .0925F;
        float salesTaxFloat;
        double total;

        Scanner inputScanner = new Scanner(System.in);

//Retrieve input from the keyboard and assign to variables
//System.out.print("Enter your first name: ");
//firstNameString = inputScanner.next();

        System.out.print("Please enter your first name: ");
        firstNameString= inputScanner.next();

        System.out.print("Enter item 1 price: ");
        number1double= inputScanner.nextDouble();

        System.out.print("Enter item 2 price: ");
        number2double = inputScanner.nextDouble();

        System.out.print("Enter item 3 price: ");
        number3double = inputScanner.nextDouble();

        System.out.print("Enter the salestax: ");
        salesTaxFloat = inputScanner.nextFloat();

//Declare constant
        final float SALES_TAXFloat = .0925F;


//Do some arithmetic
        subTotal = number1double + number2double + number3double;
        System.out.println("subtotal = " + subTotal + " ");
        salesTaxFloat = (float) (subTotal * .0925F);
        System.out.println("salesTax = " + salesTaxFloat + " ");

//display the input obtained
        System.out.print(" your name is: " + firstNameString);
        System.out.print(" your subtotal is: " +(number1double+number2double+number3double));
        System.out.print(" your salestax is: " + salesTaxFloat);
        System.out.print(" your total is: " +(subTotal+salesTaxFloat));

    }//End of main method

}//End of ScannerApplication