0% found this document useful (0 votes)
7 views

Java Project

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Java Project

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

import java.util.

InputMismatchException;

import java.util.Scanner;

public class Main {

static Scanner scanner = new Scanner(System.in);

static class Patient {

String name;

String number;

String address;

void getdata() {

System.out.print("\nEnter Patient Name: ");

name = scanner.next();

System.out.print("Enter Phone Number: ");

number = scanner.next();

System.out.print("Enter Address: ");

address = scanner.next();

void showdata() {

System.out.println("\nPatient Name: " + name);

System.out.println("Phone Number: " + number);

System.out.println("Address: " + address);

static class Doctor {

String name;

String degree;
void getedu() {

System.out.print("Enter the Doctor Name: ");

name = scanner.next();

System.out.print("Enter Doctorate Degree: ");

degree = scanner.next();

void showedu() {

System.out.println("\nDoctor Name: " + name);

System.out.println("Doctorate Degree: " + degree);

static class Appointment {

String name;

String phno;

String address;

String doctorName;

void getapp() {

System.out.print("Enter the Patient Name: ");

name = scanner.next();

System.out.print("Enter Phone Number: ");

phno = scanner.next();

System.out.print("Enter Address: ");

address = scanner.next();

System.out.print("Enter Doctor Name: ");

doctorName = scanner.next();

System.out.println("Appointment made successful.");

}
public static void main(String[] args) {

int username, password;

int cUsername = 0, cPassword = 0;

username = 123;

password = 123;

try {

System.out.print("Username: ");

cUsername = scanner.nextInt();

System.out.print("Password: ");

cPassword = scanner.nextInt();

} catch (InputMismatchException e) {

System.out.println("Invalid input. Please enter an integer.");

return; // exit the program

if (username == cUsername && password == cPassword) {

int choice;

System.out.println("================================================");

System.out.println("| Hospital Management System |");

System.out.println("| ---------------------------- |");

System.out.println("| Press 1 for Edit Patient Details. |");

System.out.println("| Press 2 for Edit Doctor Details. |");

System.out.println("| Press 3 for Edit Appointment Details. |");

System.out.println("================================================");

System.out.print("\nEnter the Choice: ");

choice = scanner.nextInt();

if (choice == 1) {
Patient patient = new Patient();

int subChoice;

System.out.println("=========================================");

System.out.println("| Press 1 to enter Patient details |");

System.out.println("| Press 2 to view Patient details |");

System.out.println("=========================================");

subChoice = scanner.nextInt();

if (subChoice == 1) {

patient.getdata();

} else if (subChoice == 2) {

patient.showdata();

} else {

System.out.println("Invalid entry.");

} else if (choice == 2) {

Doctor doctor = new Doctor();

int subChoice;

System.out.println("=========================================");

System.out.println("| Press 1 to enter Doctor details |");

System.out.println("| Press 2 to view Doctor details |");

System.out.println("=========================================");

subChoice = scanner.nextInt();

if (subChoice == 1) {

doctor.getedu();

} else if (subChoice == 2) {

doctor.showedu();

} else {

System.out.println("Invalid entry.");

}
} else if (choice == 3) {

Appointment appointment = new Appointment();

appointment.getapp();

} else {

System.out.println("Invalid entry.");

} else {

System.out.println("Invalid username or password.");

You might also like