Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

( Using the Java language) PLEASE: Keep the programs AS SIMPLE as possible. No g

ID: 3544044 • Letter: #

Question

( Using the Java language)


PLEASE: Keep the programs AS SIMPLE as possible. No going into complex methods or fancy stuff. I am a very new programmer, and need it to just work. I do not care how efficient the program is. Just needs to work and produce correct reults.



Problem 1 : A user puts some money into a savings account. Each month, they might (or might not) make a deposit into that account. The amount of the deposit can vary from month to month. They will not make any withdrawals. Interest is paid on the account once a month.


The program should determine how long it will take for the savings account to double in worth from its initial value.


Problem 2:


Write a program that allows a teacher to compute the average grades for EACH student in his or her class (NOT a single average for the entire class).


Thank you!



Explanation / Answer

Q1)


import java.util.*;


import java.lang.*;


import java.io.*;



class BankAcc


{


private String name;


private String AccNo;


private double Balance;


BankAcc(String name, String AccNo)


{


this.name = name;


this.AccNo = this.AccNo;


Balance = 0.0;


}


public void deposit(double amount)


{


Balance += amount;


}




public double getBalance()


{


return Balance;


}


}



class driver


{


public static void main (String[] args)


{


BankAcc test = new BankAcc("Prasham Mishra","24XUY89065");


test.deposit(10000);


/*Suppose if rate of interest is 10%, the interest is 1000.If the user doesn't make any deposits these months,the worst casetime is,*/

double months = 10000/1000;

System.out.println("No: of months required is : "+months);


}


}



Q2)


import java.util.*;

import java.lang.*;

import java.io.*;


class Grade

{

public static int [ ] getScores(int [ ] exams, int [ ] finals, int [ ] assignments)

{

Scanner scan = new Scanner(System.in);

System.out.println("How many Finals? ");

int f = new Integer(scan.nextLine());

System.out.println("How many Exams? ");

int e = new Integer(scan.nextLine());

System.out.println("How many Assignments? ");

int a = new Integer(scan.nextLine());

int countArray[] = new int[3];

countArray[0] = f;

countArray[1] = e;

countArray[2] = a;

int i = 0;

while(f!=0)

{

System.out.println("Enter Final Grade: ");

finals[i] = new Integer(scan.nextLine());

i++;

f--;

}

i = 0;

while(e!=0)

{

System.out.println("Enter Exam Grade: ");

exams[i] = new Integer(scan.nextLine());

i++;

e--;

}

i = 0;

while(a!=0)

{

System.out.println("Enter Assignment Grade: ");

assignments[i] = new Integer(scan.nextLine());

i++;

a--;

}

return countArray;

}

public static void calcGrage(String first, String last)

{

int exams[] = new int[100];

int finals[] = new int[100];

int assignments[] = new int[100];

int temp = 0;

while(temp<100)

{

exams[temp] = -1;

finals[temp] = -1;

assignments[temp] = -1;

temp++;

}

int scores[] = getScores(exams,finals,assignments);

Double Exam = 0.0,Final = 0.0,Assignment = 0.0;

int i=0;

while(i<scores[1])

{

Exam += exams[i];

i++;

}

Exam = Exam/scores[1];

i=0;

while(i<scores[0])

{

Final += finals[i];

i++;

}

Final =Final/scores[0];

i=0;

while(i<scores[2])

{

Assignment += assignments[i];

i++;

}

Assignment =Assignment/scores[2];

Double total = (45*Exam)/100 + (40*Assignment)/100 + (15*Final)/100 ;

String grade;

System.out.println("Average Grade is : "+ total);

if(93<= total && total<= 100)

grade = "A";

else if(90<= total && total<= 92)

grade = "A-";

else if(87<= total && total<= 89)

grade = "B+";

else if(83<= total && total<= 86)

grade = "B";

else if(80<= total && total<= 82)

grade = "B-";

else if(77<= total && total<= 79)

grade = "C+";

else if(73<= total && total<= 76)

grade = "C";

else if(70<= total && total<= 72)

grade = "C-";

else if(67<= total && total<= 69)

grade = "D+";

else if(63<= total && total<= 66)

grade = "D";

else if(60<= total && total<= 62)

grade = "D-";

else

grade = "F";

System.out.println(first + " " + last + " your letter Grade is : " + grade);

}

public static void main (String[] args)

{

Scanner scan = new Scanner(System.in);

System.out.println("Enter First Name: ");

String first = scan.nextLine();

System.out.println("Enter Last Name: ");

String last = scan.nextLine();

calcGrage(first, last);

}

}