My problem here is displaying the data using another method. I tried both of the methods but there was no output.
I think that objects in the ArrayList are gone when I made them as parameters on both methods or maybe not.
Please kindly help me with this problem of mine. There are still more options to be filled, I also need some help for it.
public class Student {
private String IDNumber;
private String firstName;
private String middleName;
private String lastName;
private String degree;
private int yearLevel;
public Student() {
this.IDNumber = IDNum;
this.firstName = fName;
this.middleName = mName;
this.lastName = lName;
this.degree = deg;
this.yearLevel = level;
}
public void setIdNumber(String IDNumber) {
this.IDNumber = IDNumber;
}
public String getIdNumber() {
return IDNumber;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return firstName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getMiddleName()
{
return middleName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return lastName;
}
public void setDegree(String degree) {
this.degree = degree;
}
public String getDegree() {
return degree;
}
public void setYearLevel(int yearLevel) {
this.yearLevel = yearLevel;
}
public int getYearLevel() {
return yearLevel;
}
/* #Override
public String toString(){
return ("ID Number: "+this.getIdNumber()+
"\nName: "+ this.getFirstName()+
" "+ this.getMiddleName()+
" "+ this.getLastName()+
"\nDegree and YearLevel: "+ this.getDegree() +
" - " + this.getYearLevel());
} */
}
import java.util.ArrayList;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
menu();
}
public static void menu() {
Scanner in = new Scanner(System.in);
int choice = 0;
System.out.print("****STUDENT RECORD SYSTEM****\n\n");
System.out.println("\t MENU ");
System.out.println("[1]ADD STUDENT");
System.out.println("[2]DISPLAY ALL");
System.out.println("[3]DISPLAY SPECIFIC");
System.out.println("[4]UPDATE");
System.out.println("[5]AVERAGE");
System.out.println("[6]EXIT");
System.out.println("?");
choice = in.nextInt();
if (choice == 1) {
options();
}
else if (choice == 2) {
displayAll(student, studentList);
}
else if (choice == 3) {
displaySpecific(student, studentList);
}
}
public static void options() {
Scanner in = new Scanner(System.in);
ArrayList<Student> studentList = new ArrayList<Student>();
char ans;
String temp;
int total;
do {
System.out.println("TOTAL: ");
total = in.nextInt();
Student[] student = new Student[total];
for (int index = 0; index < student.length; index++) {
student[index] = new Student();
System.out.print("*********STUDENT INFORMATION*********\n\n");
System.out.println("PRESS ENTER");
in.nextLine();
System.out.print("ID NUMBER: ");
student[index].setIdNumber(in.nextLine());
System.out.print("FIRST NAME: ");
student[index].setFirstName(in.nextLine());
System.out.print("MIDDLE NAME: ");
student[index].setMiddleName(in.nextLine());
System.out.print("LAST NAME: ");
student[index].setLastName(in.nextLine());
System.out.print("DEGREE: ");
student[index].setDegree(in.nextLine());
System.out.print("YEAR LEVEL: ");
student[index].setYearLevel(in.nextInt());
studentList.add(student[index]);
}
System.out
.print("Would you like to enter in a new student (y/n)? ");
String answer = in.next();
ans = answer.charAt(0);
} while (ans == 'y');
// SEARCH and DISPLAY SPECIFIC
String id = new String();
in.nextLine();
System.out.print("Enter ID NUMBER: ");
id = in.nextLine();
for (int j = 0; j < studentList.size(); j++) {
if (id.equals(studentList.get(j).getIdNumber())) {
System.out.printf("STUDENT SEARCHED");
System.out.print("\nID NUMBER: "
+ studentList.get(j).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(j).getFirstName() + " "
+ studentList.get(j).getMiddleName() + " "
+ studentList.get(j).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(j).getDegree() + "-"
+ studentList.get(j).getYearLevel() + "\n\n");
System.out.println();
}
}
// DISPLAY ALL
for (int i = 0; i < studentList.size(); i++) {
System.out.printf("STUDENT[%d]", i + 1);
System.out
.print("\nID NUMBER: " + studentList.get(i).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(i).getFirstName() + " "
+ studentList.get(i).getMiddleName() + " "
+ studentList.get(i).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(i).getDegree() + "-"
+ studentList.get(i).getYearLevel());
System.out.println();
}
menu();
}
public static void displayAll(Student student,
ArrayList<Student> studentList) {
System.out.printf("STUDENT RECORD");
for (int i = 0; i < studentList.size(); i++) {
System.out.printf("STUDENT[%d]", i + 1);
System.out
.print("\nID NUMBER: " + studentList.get(i).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(i).getFirstName() + " "
+ studentList.get(i).getMiddleName() + " "
+ studentList.get(i).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(i).getDegree() + "-"
+ studentList.get(i).getYearLevel());
System.out.println();
}
}
public static void displaySpecific(Student student,
ArrayList<Student> studentList) {
String id = new String();
in.nextLine();
System.out.print("Enter ID NUMBER: ");
id = in.nextLine();
for (int j = 0; j < studentList.size(); j++) {
if (id.equals(studentList.get(j).getIdNumber())) {
System.out.printf("STUDENT SEARCHED");
System.out.print("\nID NUMBER: "
+ studentList.get(j).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(j).getFirstName() + " "
+ studentList.get(j).getMiddleName() + " "
+ studentList.get(j).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(j).getDegree() + "-"
+ studentList.get(j).getYearLevel() + "\n\n");
System.out.println();
}
}
}
}
Move
ArrayList <Student> studentList = new ArrayList <Student>();
from options method to class field.
EDIT:
As you can see, now studentList is not a local variable of
public static void options()
but of the class.
Anyway i edited the args of some methods because you don't need to pass students as argument since now it's a field of the class.
import java.util.ArrayList;
import java.util.Scanner;
public class test {
static ArrayList<Student> studentList = new ArrayList<Student>();
public static void main(String[] args) {
menu();
}
public static void menu() {
Scanner in = new Scanner(System.in);
int choice = 0;
System.out.print("****STUDENT RECORD SYSTEM****\n\n");
System.out.println("\t MENU ");
System.out.println("[1]ADD STUDENT");
System.out.println("[2]DISPLAY ALL");
System.out.println("[3]DISPLAY SPECIFIC");
System.out.println("[4]UPDATE");
System.out.println("[5]AVERAGE");
System.out.println("[6]EXIT");
System.out.println("?");
choice = in.nextInt();
if (choice == 1) {
options();
}
else if (choice == 2) {
displayAll();
}
else if (choice == 3) {
displaySpecific(student);// here you should ask to the user what studend he want to show - here it continues to give you error
}
}
public static void options() {
Scanner in = new Scanner(System.in);
char ans;
String temp;
int total;
do {
System.out.println("TOTAL: ");
total = in.nextInt();
Student[] student = new Student[total];
for (int index = 0; index < student.length; index++) {
student[index] = new Student();
System.out.print("*********STUDENT INFORMATION*********\n\n");
System.out.println("PRESS ENTER");
in.nextLine();
System.out.print("ID NUMBER: ");
student[index].setIdNumber(in.nextLine());
System.out.print("FIRST NAME: ");
student[index].setFirstName(in.nextLine());
System.out.print("MIDDLE NAME: ");
student[index].setMiddleName(in.nextLine());
System.out.print("LAST NAME: ");
student[index].setLastName(in.nextLine());
System.out.print("DEGREE: ");
student[index].setDegree(in.nextLine());
System.out.print("YEAR LEVEL: ");
student[index].setYearLevel(in.nextInt());
studentList.add(student[index]);
}
System.out
.print("Would you like to enter in a new student (y/n)? ");
String answer = in.next();
ans = answer.charAt(0);
} while (ans == 'y');
// SEARCH and DISPLAY SPECIFIC
String id = new String();
in.nextLine();
System.out.print("Enter ID NUMBER: ");
id = in.nextLine();
for (int j = 0; j < studentList.size(); j++) {
if (id.equals(studentList.get(j).getIdNumber())) {
System.out.printf("STUDENT SEARCHED");
System.out.print("\nID NUMBER: "
+ studentList.get(j).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(j).getFirstName() + " "
+ studentList.get(j).getMiddleName() + " "
+ studentList.get(j).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(j).getDegree() + "-"
+ studentList.get(j).getYearLevel() + "\n\n");
System.out.println();
}
}
// DISPLAY ALL
for (int i = 0; i < studentList.size(); i++) {
System.out.printf("STUDENT[%d]", i + 1);
System.out
.print("\nID NUMBER: " + studentList.get(i).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(i).getFirstName() + " "
+ studentList.get(i).getMiddleName() + " "
+ studentList.get(i).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(i).getDegree() + "-"
+ studentList.get(i).getYearLevel());
System.out.println();
}
menu();
}
public static void displayAll() {
for (int i = 0; i < studentList.size(); i++) {
System.out.printf("STUDENT[%d]", i + 1);
System.out
.print("\nID NUMBER: " + studentList.get(i).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(i).getFirstName() + " "
+ studentList.get(i).getMiddleName() + " "
+ studentList.get(i).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(i).getDegree() + "-"
+ studentList.get(i).getYearLevel());
System.out.println();
}
}
public static void displaySpecific(Student student) {
String id = new String();
in.nextLine();
System.out.print("Enter ID NUMBER: ");
id = in.nextLine();
for (int j = 0; j < studentList.size(); j++) {
if (id.equals(studentList.get(j).getIdNumber())) {
System.out.printf("STUDENT SEARCHED");
System.out.print("\nID NUMBER: "
+ studentList.get(j).getIdNumber());
System.out.print("\nFULL NAME: "
+ studentList.get(j).getFirstName() + " "
+ studentList.get(j).getMiddleName() + " "
+ studentList.get(j).getLastName());
System.out.print("\nDEGREE and YEAR: "
+ studentList.get(j).getDegree() + "-"
+ studentList.get(j).getYearLevel() + "\n\n");
System.out.println();
}
}
}
}
Related
Essentially i've isolated the issue, the int numpersons begins as 0. I take a user input to make it a particular number which is the array size, when the second method begins it takes the 0 again and then the array has an out of bounds exception. I want to pass it from one method to the next, or make them more successive, idk how to do this
thanks in advance
import java.util.Scanner;
public class BankApp {
Scanner input = new Scanner(System.in);
int numpersons = 0;
private SavingsAccount[] clients = new SavingsAccount[numpersons];
public BankApp() {
while (numpersons < 1) {
System.out.println("How many people are there?");
numpersons = input.nextInt();
if (numpersons < 1 || 2147483647 < numpersons) {
System.out.println("invalid number, please enter again");
}
}
input.nextLine();
}
public void addClients() {
int i = 0;
while (i < numpersons) {
System.out.println("enter account id " + (i + 1));
String AccountID = input.nextLine();
System.out.println("enter account name " + (i + 1));
String AccountName = input.nextLine();
System.out.println("enter account balance " + (i + 1));
Double AccountBalance = input.nextDouble();
clients[i] = new SavingsAccount(AccountID, AccountName, AccountBalance);
input.nextLine();
i++;
}
}
public void displayClients() {
int i = 0;
while (i < numpersons) {
System.out.println("======================================");
System.out.println("Account ID " + (i + 1) + ": " + clients[i].getID());
System.out.println("Account Name " + (i + 1) + ": " + clients[i].getName());
System.out.println("Account Balance " + (i + 1) + ": " + clients[i].getBalance());
System.out.println("======================================");
i++;
}
}
public static void main(String args[]) {
BankApp ba = new BankApp();
ba.addClients();
ba.displayClients();
}
}
I'm learning Java for a week, and now i have a problem, because i want to print all Arraylist in method printArray, but the method don't see getName() and other methods and I don't know how to solve my problem. Thanks a lot for your help.
If you can, please show my what I;m doing wrong.
Class Positions:
public class Positions {
List<Positions> list = new ArrayList<>(15);
int ageAdd;
int IDAdd;
String nameAdd;
int counter;
String name;
int age;
int ID;
public Positions(String name, int age, int ID) {
this.name = name;
this.age = age;
this.ID = ID;
}
public Positions() {
this("", 0, 0);
}
//there are methods:
//adding element
//removing element
//changing values
//etc
public String getName() {
return name;
}
public int getAge() {
return age;
}
public int getID() {
return ID;
}
public void printArray() {
for (int i = 0; i < list.size(); i++) {
System.out.println(i + " : " + " NAME: " + list.getName(i) + " AGE: " + list.getAge(i) + " ID: " list.getID(i));
}
}
Class main:
public class ArrayList2
{
public static void main (String[] args)
{
Positions p = new Positions();
System.out.println("----LISTA TABLICOWA-----");
System.out.println("Co chcesz wykonać? ");
System.out.println("1. Dodac element do listy. ");
System.out.println("2. Usunac elemnt z listy.");
System.out.println("3. Wstawić na dowolna pozycje.");
System.out.println("4. Rozmiar listy.");
System.out.println("5. Zmienic wartosc na podanym indeksie.");
System.out.println("6. Wyświetlić listę. ");
while(true) {
System.out.println("podaj pozycję: ");
Scanner ch = new Scanner(System.in);
int choice= ch.nextInt();
switch (choice)
{
case 1:
{
p.addPosition(); //?
break;
}
case 2:
{
p.removePosition();
break;
}
case 3:
{
p.setOnAnyPosition();
break;
}
case 4:
{
p.ArraySizeShow();
break;
}
case 5:
{
p.changePosition();
break;
}
case 6:
{
p.printArray();
break;
}
}
}
}
}
You simply have a problem with the array access:
Instead of using:
public void printArray() {
for (int i = 0; i < list.size(); i++) {
System.out.println(i + " : " + " NAME: " + list.getName(i) ...);
}
}
You should use:
public void printArray() {
for (int i = 0; i < list.size(); i++) {
System.out.println(i + " : " + " NAME: " + list.get(i).getName() ...);
}
}
because you want to get the name of a specific element, and in OO languages, that usually means calling the method on the object itself.
Ijn your example, you have a list that contains objects that contains a name. So if you want to access the name from the list, you need to first get an element then get his name.
HTH.
Try to change method with below code. Hope it would help.
public void printArray() {
for (int i = 0; i < list.size(); i++) {
System.out.println(i + " : " + " NAME: " + list.get(i).getName() + " AGE: " + list.get(i).getAge() + " ID: " list.get(i).getID());
}
}
To loop over your list either use
for (int i = 0; i < list.size(); i++) {
Positions p = list.get(i);
System.out.println(i + " : " + " NAME: " + p.getName() + " AGE: " + p.getAge() + " ID: " + p.getID());
}
or
int index =0;
for (Positions p : list) {
System.out.println(index++ + " : " + " NAME: " + p.getName() + " AGE: " + p.getAge() + " ID: " + p.getID());
}
This question already has answers here:
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
(18 answers)
Closed 3 years ago.
Compiler throws an exception saying:
Cannot find symbol p and x
This program takes user input and prints as per the loop condition. While compiling it throws an error that it cannot find the symbol.
import java.util.Scanner;
class Puppy{
String name;
String breed;
String gender;
int weight;
int age;
int loud;
void hammer()
{
System.out.println("Enter your Dogs name :");
p[x].name = user_input.next();
System.out.println("Enter your Dogs Breed :");
p[x].breed = user_input.next();
System.out.println("Enter your Dogs Gender :");
p[x].gender = user_input.next();
System.out.println("Enter your Dogs weight in Kg:");
p[x].weight = user_input.nextInt();
System.out.println("Enter your Dogs age :");
p[x].age = user_input.nextInt();
System.out.println("Rate your Dogs Loudness out of 10 :");
p[x].loud = user_input.nextInt();
}
void jammer()
{
System.out.println("Hello my name is" + " " + p[x].name);
System.out.println("I am a" + " " + p[x].breed);
System.out.println("I am" + " " + p[x].age + " " + "years old" + " " + p[x].gender);
System.out.println("I weigh around" + " " + p[x].weight + " " + "kg's");
System.out.println("I sound this loud" + " " + p[x].loud);
}
}
class PuppyTestDrive
{
public static void main(String []args)
{
Scanner user_input = new Scanner(System.in);
int x = 0;
Puppy[] p = new Puppy[4];
while(x < 4)
{
p[x] = new Puppy();
p[x].hammer();
p[x].jammer();
x = x + 1;
}
}
}
Your program should work with the following code:
import java.util.Scanner;
class Puppy{
String name;
String breed;
String gender;
int weight;
int age;
int loud;
void hammer()
{
Scanner user_input = new Scanner(System.in);
System.out.println("Enter your Dogs name :");
this.name = user_input.next();
System.out.println("Enter your Dogs Breed :");
this.breed = user_input.next();
System.out.println("Enter your Dogs Gender :");
this.gender = user_input.next();
System.out.println("Enter your Dogs weight in Kg:");
this.weight = user_input.nextInt();
System.out.println("Enter your Dogs age :");
this.age = user_input.nextInt();
System.out.println("Rate your Dogs Loudness out of 10 :");
this.loud = user_input.nextInt();
}
void jammer()
{
System.out.println("Hello my name is" + " " + this.name);
System.out.println("I am a" + " " + this.breed);
System.out.println("I am" + " " + this.age + " " + "years old" + " " + this.gender);
System.out.println("I weigh around" + " " + this.weight + " " + "kg's");
System.out.println("I sound this loud" + " " + this.loud);
}
}
class PuppyTestDrive {
public static void main(String []args)
{
int x = 0;
Puppy[] p = new Puppy[4];
while(x < 4)
{
p[x] = new Puppy();
p[x].hammer();
p[x].jammer();
x = x + 1;
}
}
}
In my code below, I am having an issue where I add the customer name to one room, but instead it adds the customer to every room. I can't figure out what in my code the issue is. I have tried removing the procedure but that still produced the same problem.
package test;
import java.util.*;
public class test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String choice, custName = "";
int roomNum = 1;
String[] hotel = new String[12];
String[] customer = new String[12];
hotelInitialise(hotel);
custInitialise(customer);
while ( roomNum < hotel.length-1 ) {
for (int i = 0; i < hotel.length-1; i++) {
System.out.println("This is the Hotel Menu. Please choose from the following options:\n");
System.out.println("A: " + "This will add a new entry\n");
System.out.println("V: " + "View all rooms\n");
choice = input.next().toUpperCase();
if (choice.equals("A")) {
System.out.println("Enter room number(1-10)");
roomNum =input.nextInt();
System.out.println("Enter name for room " + roomNum + " : " ) ;
custName = input.next();
addNewBooking(hotel, custName);
System.out.println(" ");
}
if (choice.equals("V")) {
seeAllRooms(hotel, custName);
}
}
}
}
// When the program loads it will assign all the values of the array as being empty
private static void hotelInitialise( String hotelRef[] ) {
for (int x = 0; x < 11; x++){
hotelRef[x] = "Room " + x + " is empty.";
}
System.out.println( "Welcome to the Summer Tropic Hotel.\n");
}
private static void custInitialise (String custRef[]) {
for (int i = 0; i < 11; i++) {
custRef[i] = ", no customer has occupied this room";
}
}
private static void addNewBooking(String hotel[], String customer) {
for (int x =1; x <11; x++) {
if (hotel[x].equals("Room " + hotel[x] + " is empty."))
System.out.println("Room " + x + " is empty.");
else {
System.out.println("Room " + x + " is occupied by "+ customer);
}
}
}
private static void seeAllRooms(String hotel[], String customer) {
for (int i = 0; i < hotel.length-1; i++) {
int j=0;
String custName = customer;
hotel[j]= custName;
if (hotel[i].equals("Room " + i + " is empty."))
System.out.println("Room " + i + " is empty.");
else {
System.out.println("Room " + i + " is occupied by "+ hotel[j] + ".");
}
}
}
}
In addNewBooking method you have this line:
if (hotel[x].equals("Room " + hotel[x] + " is empty."))
However hotel[x] has a value of "Room x is empty" e.g. hotel[1] is "Room 1 is empty" So the final check is becoming "hotel[x].equals(Room Room x is empty is empty.)" which is never equals to your hotel[x]
You have to change your code to
if (hotel[x].equals("Room " + x + " is empty."))
//do something there like add the booking
Im solving a question on java and im having some problems, im a beginner so plse help , my print statements(name and department) clash with each other when taking values from the user.
public class payroll2
{
public static void main(String args[])
{
payroll2 payroll = new payroll2();
payroll.SetPayrollDetail();
payroll.SetBonus();
payroll.SetCommission();
payroll.SetNssf();
payroll.SetNetSalary();
payroll.GetPayroll();
}
Scanner myScanner=new Scanner(System.in);
int empID;
String empName;
String empDept;
String designation;
int basicSalary;
double netSal;
double bonus;
double commission;
double nssf;
public void SetPayrollDetail()
{
System.out.println("Enter ID: ");
empID = myScanner.nextInt();
System.out.println("Enter Name: ");
empName = myScanner.nextLine();
System.out.println("Enter Department (Marketing or Other): ");
empDept = myScanner.nextLine();
System.out.println("Enter Designation (Manager, Executive or Other):");
designation = myScanner.nextLine();
System.out.println("Enter Basic Salary: ");
basicSalary = myScanner.nextInt();
}
public void SetBonus()
{
if(basicSalary < 1500){
bonus = 0.0;
}
else if(basicSalary>=1500 && basicSalary<3000){
bonus = basicSalary * (12.0/100.0);
}
else if(basicSalary>=3000 && basicSalary<5000){
bonus = basicSalary * (15.0/100.0);
}
else{
bonus = basicSalary * (25.0/100.0);
}
}
public void SetCommission()
{
if( empDept.equalsIgnoreCase("other") ){
commission = 0.0;
}
else if( empDept.equalsIgnoreCase("marketing") && designation.equalsIgnoreCase("manager") ){
commission = basicSalary * (30.0/100.0);
}
else if( empDept.equalsIgnoreCase("marketing") && designation.equalsIgnoreCase("executive") ){
commission = basicSalary * (15.0/100.0);
}
else if( empDept.equalsIgnoreCase("marketing") && designation.equalsIgnoreCase("other") ){
commission = basicSalary * (10.0/100.0);
}
else{
commission = 0.0;
}
}
public void SetNssf()
{
if(basicSalary < 1500){
nssf = basicSalary * (5.0/100.0);
}
else if(basicSalary>=1500 && basicSalary<3000){
nssf = basicSalary * (8.0/100.0);
}
else if(basicSalary>=3000 && basicSalary<5000){
nssf = basicSalary * (12.0/100.0);
}
else if(basicSalary>=5000 && basicSalary<7000){
nssf = basicSalary * (15.0/100.0);
}
else if(basicSalary>=7000 && basicSalary<10000){
nssf = basicSalary * (20.0/100.0);
}
else{
nssf = basicSalary * (25.0/100.0);
}
}
public void SetNetSalary()
{
netSal=(basicSalary + commission + bonus) - nssf;
}
public void GetPayroll()
{
System.out.println("\n\n\n\t\tPayroll Details \n____________________________________________________\n");
System.out.println("Employee Id : " + empID + "\t\t Bonus : " + bonus);
System.out.println("Name : " + empName + "\t\t\t\t Commission : " + commission);
System.out.println("Department : " + empDept + "\t\t NSSF : " + nssf);
System.out.println("Designation : " + designation + "\t\t NetSalary : " + netSal);
System.out.println("Basic Salary : " + basicSalary + "\n");
}
}
Edit on:
public void SetPayrollDetail()
{
System.out.println("Enter ID: ");
empID = myScanner.nextInt();
System.out.println("Enter Name: ");
empName = myScanner.next();
System.out.println("Enter Department (Marketing or Other): ");
empDept = myScanner.next();
System.out.println("Enter Designation (Manager, Executive or Other):");
designation = myScanner.next();
System.out.println("Enter Basic Salary: ");
basicSalary = myScanner.nextInt();
}
myScanner.next();