Java OOP Assignment: Student Data and Financial Analysis

Verified

Added on  2022/11/30

|9
|1142
|153
Practical Assignment
AI Summary
This Java assignment presents a solution for an Object-Oriented Programming (OOP) task. The program is designed to manage student data and perform financial calculations. The code includes classes for 'Person' and 'Calculate', enabling the input of student names, IDs, salaries, and expenses. The program then calculates savings, and estimates the time needed to save for a down payment on a house based on entered rent preferences. The solution incorporates user input through the console, providing a menu-driven interface for data entry and retrieval. The program also displays average yearly savings and provides a summary of financial data based on the input from five users. The code demonstrates the application of OOP principles such as encapsulation and modularity, providing a practical example of Java programming for financial analysis and data management. The assignment solution is designed to help students understand and apply OOP concepts in a real-world scenario.
Document Page
Object Oriented Programming with Java
Name of the Student:
Name of the University:
Author note:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Source Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication31;
import java.util.Scanner;
/**
*
* @author LAPTOP_MP340
*/
class Person{
String name[]= new String[50];
String roll[]= new String[20];
Scanner sc= new Scanner(System.in);
Document Page
int j;
void getDetails(){
System.out.print("Enter Student Name :");
name[j]=sc.nextLine();
System.out.print("Enter Student ID:");
roll[j]=sc.nextLine();
}
void show(){
System.out.println("\
n#############################################################");
System.out.println("\nThank you using this system");
System.out.println("\nGood Bye");
System.out.println("\nStudent ID :"+roll[j]);
System.out.println("\nStudent Name :"+name[j]);
System.out.println("\
n###########################################################"
+ "");
Document Page
}
}
class Calculate{
int price = 0, years=0, year;//[] salary = new int[10];
int[] expenses = new int[10];
int[] rent = new int[10];
int i;
Scanner sc= new Scanner(System.in);
int calculate(int rent[]){
for(i=0; i<5;i++){
if(rent[i]<500000){
price +=(rent[i]*5)/100;}
else if(rent[i]<=1000000){
price+=(rent[i]*10)/100;
}
else{
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
price=(rent[i]*15)/100;
}
years+=rent[i]/price;
}
System.out.println("\nSaving down payment : $"+price);
return years;
}
}
public class JavaApplication31 {
public static void main(String args[])
throws java.io.IOException {
int n,ch,i,j = 0, saving=0, sum=0, sum1=0, down_payment=0, savings = 0, year;
Document Page
int[] salary = new int[10];
int[] expenses = new int[10];
int[] rent = new int[10];
int[] price = new int[10];
String name[]= new String[50];
String roll[]= new String[20];
Scanner sc=new Scanner(System.in);
Calculate c=new Calculate();
Person p=new Person();
//System.out.println("Enter the number of person : ");
//n=sc.nextInt();
while(true) {
System.out.println(" 1. Start");
System.out.println(" 2. Exit\n");
System.out.println("\nChoose one option:");
Document Page
ch = sc.nextInt();
switch(ch) {
case 1:
for (i=0; i<5; i++){
System.out.println("\nStudent "+(i+1)+"-> ");
p.getDetails();
System.out.print(java.time.LocalDate.now());
System.out.println("\
n######################################################");
System.out.print("Enter Salary for the Month : $");
salary[i]=sc.nextInt();
System.out.print("Enter Expeses for the Month : $");
expenses[i]=sc.nextInt();
sum+=salary[i];
sum1+=expenses[i];
savings+=(sum-sum1)/12;
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
System.out.print("Enter prerferred house rent : $");
rent[i]=sc.nextInt();
year=c.calculate(rent);
System.out.println("\
n##############################################################");
System.out.println("\nAccording to data entered from five users on current date :
"+java.time.LocalDate.now());
System.out.println("\nTheir Average yearly savings = $"+savings);
System.out.println("\nThey need average of "+year+" to save their down payment. ");
System.out.println("\nThank you for using the system. ");
System.out.println("#######################################################
#######");
}
break;
case 2: for(i=0; i<5;i++){
System.out.println("Student "+(i+1)+"-> ");
p.show();
}
Document Page
break;
case 3: System.exit(0);
default: System.out.println("Invalid selection.\n");
}
}
}
}
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]