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

I need help please , COMP 1900 - Fall 2018 Lab 3: Conditionals (12 pts) Number o

ID: 3751114 • Letter: I

Question

I need help please ,

COMP 1900 - Fall 2018 Lab 3: Conditionals (12 pts) Number of Peopis: Individual Dus: By the end of your lab session today. You MUST submit dis before leaving the lab Grader Please refer to the COMP 1900 syllabus for your lab TA. Questions about grading? Contact him ber firt Coding Style: Use camelCase for variable names, use consistent indentaticn in your code, and include a reasonable asount of comments throughout your code. The TAs may deduct points for poor coding style Within the 1900 folder on your desktop, create a new folder named Labs Suppose that a university uses the following scherme to compute tuition fees. This is loosely based on how ahe U of M actually does it . Tuition costs $400 per eredit hour for each bour up to and including 12 . For each hour beyond 12, the cost is $60 per credit hour Engineering and science courses are charged an extra lab foe of $25 per credit hou Exampls l: Alvin is taking 9 hours, 3 of which are from engineering/science courses. His tuition is calculated like this ($400 per credit hour up to 12) (9 credit hours)$3600 ($25 per E/S credit hour)(3 credit hours) TOTAL S75 53675 Example 2 Brooke is taking 17 hours, 14 of which are from engineering/science courses. (Brooke is not a happy student.) Her tuition is calculated like this: ($400 per credit hour up to 12) (12 credit hours)$4800 ($60 per credit hour beyond 12) (5 credit hours) $300 ($25 per E/S credit hour) (14 credit hours) TOTAL 350 $5450 Lab Assignment 1. (4 pts) Before we write a program to do anything, it's essential that we have a good understanding of the problem we're trying to solve. One way of doing this is to start by developing a set of test cases Remember from your last lab homework that a test case is a set of program inputs that has a known output. In the lab homework, you wrote a test case after you wrote your program. Here we're going to write some test cases before we start writing the program. This technique is called test-drivern development. Writing the tests first can sometimes give insight into how to solve the probiem

Explanation / Answer

Java program:

public class TutionFeeCalculator {

//main method to run application

public static void main(String[]arg) {

//CONSTANTS to use in the program

final int TUTIONFEEPERHOUR=400;

final int E_S_SERVICES=25;

final int BEYOND_COST=60;

//Scanner class object to read input from keyboar(user)

Scanner scan = new Scanner(System.in);

//asking user to input

System.out.print("Your good name please:");

String name=scan.nextLine();

System.out.print(name+",input your course hours:");

int courseHours=scan.nextInt();

System.out.print(name+",are your taking engineering/serivces courses?");

System.out.print("Enter (y) yes or (n) no:");

char engServCourses=scan.next().charAt(0);

boolean hasEngSerCourse=false;

int engServCourseHours=0;

//checking whether the student has engineering/serivces course or not

if('y'==engServCourses || 'Y'==engServCourses)

{

//if has, then ask him to enter course hours

hasEngSerCourse=true;

System.out.print("Please input engineering/serivces course hours?");

engServCourseHours=scan.nextInt();

}

System.out.println(name+" here is your TutionFee cost details: ");

/*Calculation part based on the inputs*/

int totalCourseFee=0,beyondHours=0;

if(courseHours<12) {

if(hasEngSerCourse) { //if student engineering/serivces course hours

System.out.print("($"+TUTIONFEEPERHOUR+" per credit hour upto 12)*("+courseHours+" credit hours)");

System.out.print(" = $"+(TUTIONFEEPERHOUR*courseHours));

System.out.print(" ($"+E_S_SERVICES+" per E/S credit hour)*("+(engServCourseHours+"credit hours"));

System.out.print(" = $"+(E_S_SERVICES*engServCourseHours));

//calculating total course tuition fee

totalCourseFee=(TUTIONFEEPERHOUR*courseHours) + (E_S_SERVICES*engServCourseHours);

System.out.print(" Total = $"+totalCourseFee);

}else {

System.out.print("($"+TUTIONFEEPERHOUR+" per credit hour upto 12)*("+courseHours+" credit hours)");

System.out.print(" = $"+(TUTIONFEEPERHOUR*courseHours));

//calculating total course tuition fee

totalCourseFee=(TUTIONFEEPERHOUR*courseHours);

System.out.print(" Total = $"+totalCourseFee);

}

}else { //if credit hours > 12, then this is the condition

if(hasEngSerCourse) { //if student has engineering/serivces course hours

//calculating beyond hours

beyondHours=courseHours-12;

System.out.print("($"+TUTIONFEEPERHOUR+" per credit hour upto 12)*(12 credit hours)");

System.out.print(" = $"+(TUTIONFEEPERHOUR*12));

System.out.print(" ($"+BEYOND_COST+" per credit hour beyond 12)*("+beyondHours+" credit hours)");

System.out.print(" = $"+(BEYOND_COST*beyondHours));

System.out.print(" ($"+E_S_SERVICES+" per E/S credit hour)*("+(engServCourseHours+" credit hours)"));

System.out.print(" = $"+(E_S_SERVICES*engServCourseHours));

//calculating total course tuition fee

totalCourseFee=(TUTIONFEEPERHOUR*12) + (E_S_SERVICES*engServCourseHours)+(BEYOND_COST*beyondHours);

System.out.print(" Total = $"+totalCourseFee);

}else {

//calculating beyond hours

beyondHours=courseHours-12;

System.out.print("($"+TUTIONFEEPERHOUR+" per credit hour upto 12)*(12 credit hours)");

System.out.print(" = $"+(TUTIONFEEPERHOUR*courseHours));

System.out.print(" ($"+BEYOND_COST+" per credit hour beyond 12)*("+beyondHours+" credit hours)");

System.out.print(" = $"+(BEYOND_COST*beyondHours));

//calculating total course tuition fee

totalCourseFee=(TUTIONFEEPERHOUR*12)+(BEYOND_COST*beyondHours);

System.out.print(" Total = $"+totalCourseFee);

}

}

}

}

Output: Test case 1

Your good name please:Jain

Jain,input your course hours:9

Jain,are your taking engineering/serivces courses?Enter (y) yes or (n) no:y

Please input engineering/serivces course hours?3

Jain here is your TutionFee cost details:

($400 per credit hour upto 12)*(9 credit hours) = $3600

($25 per E/S credit hour)*(3credit hours = $75

Total = $3675

Output: Test case 2

Your good name please:Alvin

Alvin,input your course hours:17

Alvin,are your taking engineering/serivces courses?Enter (y) yes or (n) no:y

Please input engineering/serivces course hours?14

Alvin here is your TutionFee cost details:

($400 per credit hour upto 12)*(12 credit hours) = $4800

($60 per credit hour beyond 12)*(5 credit hours) = $300

($25 per E/S credit hour)*(14 credit hours) = $350

Total=$5450

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote