A2 Oop
A2 Oop
java
Source code.
import java.util.ArrayList;
import java.util.Scanner;
public Restaurant() {
menu = new ArrayList<>();
}
Output
UITS.java
Source code.
import java.util.Scanner;
class UITS {
Scanner scanner = new Scanner(System.in);
void displayWelcomeMessage() {
System.out.println("Welcome to University of Information Technology and Sciences
Portal!!!");
}
void displayMenu() {
System.out.println("Select one of the following streams in which you want to study");
System.out.println("1. Computer Science");
System.out.println("2. Information Technology");
System.out.println("3. Electronics and Communication");
System.out.println("4. Electrical and Electronics");
System.out.println("5. Mechanical");
System.out.println("10. Exit");
System.out.println("Enter the choice number from above");
}
switch (stream) {
case "Computer Science":
System.out.println("DSA");
System.out.println("DBMS");
System.out.println("Computer Networks (CN)");
break;
case "Information Technology":
System.out.println("MPMC (Multi processor and Multi Controller)");
System.out.println("DBMS");
System.out.println("DSA");
System.out.println("Information Security");
break;
case "Electronics and Communication":
System.out.println("Wireless Communication");
System.out.println("Switching Theory and Logic Design (STLD)");
System.out.println("Mobile Systems Communication");
break;
case "Electrical and Electronics":
System.out.println("Switching Theory and Logic Design (STLD)");
System.out.println("Control Systems");
System.out.println("Electrical Circuits and Designs");
break;
case "Mechanical":
System.out.println("Force and Friction");
System.out.println("Motors and its Types");
break;
default:
System.out.println("Invalid choice!");
}
}
if (choice.equalsIgnoreCase("A")) {
System.out.println("Congratulations!! You are now a " + stream + " student at UITS");
} else if (choice.equalsIgnoreCase("B")) {
System.out.println("Stream selection canceled.");
} else {
System.out.println("Invalid choice! Stream selection canceled.");
}
}
void start() {
displayWelcomeMessage();
while (true) {
displayMenu();
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
if (choice == 10) {
System.out.println("Exiting...");
break;
}
switch (choice) {
case 1:
displayCourseOutline("Computer Science");
lockStream("CSE");
break;
case 2:
displayCourseOutline("Information Technology");
lockStream("IT");
break;
case 3:
displayCourseOutline("Electronics and Communication");
lockStream("ECE");
break;
case 4:
displayCourseOutline("Electrical and Electronics");
lockStream("EE");
break;
case 5:
displayCourseOutline("Mechanical");
lockStream("Mechanical");
break;
default:
System.out.println("Invalid choice!");
}
}
}
}
Output
BankManagement.java
Source code.
import java.util.Scanner;
@Override
public void deposit(double amount) {
super.deposit(amount);
// Adding 2% interest on deposit
balance += (amount * 0.02);
}
}
System.out.print("Enter S for saving customer and C for current a/c customer: ");
String accountTypeInput = scanner.nextLine().toUpperCase();
if (accountTypeInput.equals("S")) {
System.out.print("Enter Customer Name: ");
String customerName = scanner.nextLine();
switch (choice) {
case 1:
System.out.print("Enter amount to Deposit: ");
double depositAmount = scanner.nextDouble();
account.deposit(depositAmount);
break;
case 2:
System.out.print("Enter amount to Withdraw: ");
double withdrawAmount = scanner.nextDouble();
account.withdraw(withdrawAmount);
break;
case 3:
account.displayBalance();
break;
case 4:
account.displayDetails();
break;
case 5:
return;
default:
System.out.println("Invalid choice.");
}
}
}
}
Output