Thread: new program
View Single Post
Old 09-01-2012, 04:41 AM   PM User | #5
rdspoons
New Coder

 
Join Date: Jun 2009
Posts: 81
Thanks: 0
Thanked 8 Times in 8 Posts
rdspoons is on a distinguished road
Code:
//pointers?
// Allows for user input
import java.util.Scanner;

public class Salary3
{
public static void main (String[] args)			// <- 1. corrected semi-colon error on main
{							// Removed the semi-colon
// Declare Variables
String name;
double salary;

// Allows to read in from user input
Scanner scan = new Scanner (System.in);

// Prompt user for their name
System.out.println ("what is your name?");		// <-- 2. Syste was not an Object
							// Replaced Syste with System
// Read in the users name and stores it in the cariable name
name = scan.nextLine();					// <-- 3. could not divide an object by the result of an undefined function call
							// Replaced the division operator with a dot to connect the method to the object
// Prompt the user for their age
System.out.println ("What is your age?");		// <-- 4. Systems was not an object
							// Replaced Systems with System
// Read in the users age and stores it in the variable age
int age = scan.nextInt ();				// <-- 5. age was undclared
							// declared age as int
							// <-- 6. netInt was undefined
							// Replaced netInt with nextInt
// Prompt the user for their wanted salary
System.out.println ("How much money would you like to"
+ " make in a year");

// Read in the users salary and store it in the variable salary
salary = scan.nextDouble ();

// Output the wanted output
System.out.print ("\n" + name + " is " + age);
System.out.println (" years old and would like to make $" +
salary + " a year.");					// <-- 7. the closing double-quote was missing
} // End of main					// Added a closing quote after the period following year.
} // End of Salary
rdspoons is offline   Reply With Quote