Ok, we are building an app using NetBeans6.1 .
Console menu to
1) Add an Instructor
2) Add a student
or
3) Exit
All info must be gained through the Scanner class
Ask user if they eneter in fo for Student or Instructor
Ask Last, First, and number of years teaching or student (verify number entered with exception handler)
Store info in appropriate class (Instructor, Student, inheriting from Person as superclass)
Student class must glean info through constructor
Instructor class must glean info through Main and load using Set/Get.
Echo information back to user without using data from the classes (print from the main method)
What have I done wrong so far? (I'm trying to input data)
I get the following gibberish from the environment:
Compiling 5 source files to C:\Documents and Settings\06111246\Desktop\\build\classes
C:\Documents and Settings\06111246\Desktop\\Scanner.java:20: <identifier> expected
System.out.print("Select from the following:\n\n");
C:\Documents and Settings\06111246\Desktop\\Scanner.java:21: <identifier> expected
System.out.print("\t 1)Add an Instructor \n \t 2)Add a Student \n \t 3)Exit\n\n" );
C:\Documents and Settings\06111246\Desktop\\Scanner.java:22: <identifier> expected
System.in(Choice)
3 errors
[code]
*/import javax.swing.*;
import java.util.*;
public class Scanner extends Person{
public static void main(String args[])
public
Integer Choice;
Scanner scanner = new Scanner(System.in);
System.out.print("Select from the following:\n\n");
System.out.print("\t 1)Add an Instructor \n \t 2)Add a Student \n \t 3)Exit\n\n" );
System.in(Choice);
if (iChoice == 1 )
{
Instructor oInstructor;
oInstructor = new Instructor();
oInstructor.SetInstructor();
}
if (iChoice == 2)
{
Student oStudent;
oStudent = new Student();
oStudent.SetStudent();
}
if (iChoice == 3)
{
;
}
else
;
}
public class Instructor extends Person{
void SetInstructor()
{
System.out.print("Please enter your first name: ");
String FirstName = Scanner.scanner.next();
System.out.print("Please enter your last name: ");
String LastName = Scanner.scanner.next();
System.out.print("Enter your age: ");
Age = scanner.nextInt();
System.out.println(LastName + ", " + FirstName + ", " + Age + " years of age.");
}
}
//import javax.util.*;
public static void main(String[] args) {
//String IS;
Scanner oScanner;
oScanner = new Scanner(System.in);
Person oPerson;
oPerson = new Person();
Instructor oInstructor;
oInstructor = new Instructor();
Student oStudent;
oStudent = new Student();
*/import javax.swing.*;
import java.util.Scanner;
public class Person {
private
String FirstName;
String LastName;
String iAge;
int Age;
/*void SetStudent()
{
System.out.print("Please enter your first name: ");
String FirstName = scanner.next();
System.out.print("Please enter your last name: ");
String LastName = scanner.next();
System.out.print("Enter your age: ");
Age = scanner.nextInt();
System.out.println(LastName + ", " + FirstName + ", " + Age + " years of age.");
}*/
public class Student extends Person{
void SetStudent()
{
System.out.print("Please enter your first name: ");
String FirstName = scanner.next();
System.out.print("Please enter your last name: ");
String LastName = scanner.next();
System.out.print("Enter your age: ");
Age = scanner.nextInt();
System.out.println(LastName + ", " + FirstName + ", " + Age + " years of age.");
}
}
I only get one day a week with this stuff, unfortunately
Thanks

