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

please need help asap! Requirements are important in this assignment. Tuition Ca

ID: 3853041 • Letter: P

Question



please need help asap! Requirements are important in this assignment.

Tuition Calculation You are assigned to write a program that calculates tuition for students. The program will ask user to enter number of credit hours a student enrolled (use loop to validate the input 0) and enter if the student is resident or non-resident. Then the program will calculate the tuition on CUNY tuition chart, and print out the results. After complete one student's tuition, the program should as user to choose to continue for next student or not. If user chooses to continue, the program will repeat the process for next student; if user chooses not to, the program will end. based Requirements Your program should be well documented: brief description of program and comments at major steps. Your program must have the following methods: . boolean isValid( int credit) - return true if the credit is greater than 0, otherwise return fasle double instate tuition in credit)-will return tuition based on the number of credit for in state students o o o double outstate tuition int credit) - return tuition based on number of credit for out of state students . Check CUNY website to find out tuition policy http://www.citytech.cuny.edu/admissions/generalinfo/tuition.shtml You may only consider tution based on number of credit and resident status, ignore other fees. Test your program with different inputs

Explanation / Answer

package sample1;

import java.util.Scanner;

public class FeeCalculator {

public static boolean isValid(int credit) {

if (credit > 0)

return true;

else

return false;

}

public static double instate_tuition(int credit) {

return 3265.0 + (285.0 * credit);

}

public static double outstate_tuition(int credit) {

return 3265.0+(580.0 * credit);

}

public static void main(String args[]) {

char ch = 'Y';

// while loop to control the whole application

while (ch != 'N') {

Scanner s = new Scanner(System.in);

System.out.println(" enter no of credit hours : ");

int hours = s.nextInt();

System.out.println(" enter ( R ) for resident / (NR) for non-resident : ");

String str = s.next();

// check validity of input

if (isValid(hours)) {

if (str.equals("R")) {

System.out.println(" tuition fee : " + instate_tuition(hours));

}

if (str.equals("NR")) {

System.out.println(" tuition fee : " + outstate_tuition(hours));

}

}

System.out.println(" want to calculate for another student (Y/N) ? : ");

ch = s.next().charAt(0);

}

System.out.println(" ** exited from application **");

}

}