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

[BASIC JAVA] ** Please answer with basic java and provide some output with pictu

ID: 666801 • Letter: #

Question

[BASIC JAVA]

** Please answer with basic java and provide some output with picture. Thanks

Write a complete Java program to compute the total living cost for a semester. The main method calls four methods to do this:

1.   getTotalWeeks: requests from the user the total number of weeks they will attend college and returns this number as an integer.

2.   getDailyExpenses: requests from the user the estimated daily living expenses for each day of the week (seven values) and returns these as an array of doubles.

3.   computeLivingExpenses: takes as parameters/arguments the total number of weeks (integer value returned from the first method) and the estimated daily expenses (array of seven doubles returned from the second method) and returns a double representing the estimated total living expenses for the semester.

To compute the total living expenses, use a for loop to first compute the total weekly living expenses then multiply this number by the total number of weeks the student will be in college.

4.   printLivingExpenses: takes a double as a parameter, returns void, and outputs the living expenses to the user as a string, for example: “Your estimated living expenses for the semester are X” where X is replaced by the double parameter.

Explanation / Answer

import java.io.*; import java.util.*; import javax.swing.*; public class FinanceRev1{ private double rentExpenses, tuition, totalCost, payInput; private boolean status; private int pay; //if pay=1 > this means that the user choose Savings //if pay=2 > user choose loans //if pay=3 > user choose freelance work //totalCost=Final cost per month private String input; //***************************Constructors************************************** //default constructor public FinanceRev1(){ rentExpenses=0.0; tuition=0.0; totalCost=0.0; payInput=0.0; status=false; pay=0; } //non-default constructor public FinanceRev1(double rentExp, double tuit, boolean stat){ rentExpenses=rentExp; tuition=tuit; status=stat; } //****************************************************************************** //*****************************METHODS****************************************** //Takes that the string referenced passed as parents //("yes"/"no") and changes it to true or false //-check to see wether the input is "yes" or "no" //--checks wether the user lives with their parents //--and sets the status of this event as either true //--or false //-if input does not match up as "yes" or "no" then //-the program asks for the user to input the correct //-string again and does the re-validation and //-status setting process public void liveWithParents(String parents){ if(parents.equalsIgnoreCase("yes") || parents.equalsIgnoreCase("no")){ if(parents.charAt(0)=='y' || parents.charAt(0)=='Y') status=true; else status=false; } else{ while(!((parents.equalsIgnoreCase("yes")) || (parents.equalsIgnoreCase("no")))){ parents=JOptionPane.showInputDialog("The text entered in the"+ " -Living with parents- field is invalid. You must input a "+ "Yes/No answer:"); } if(parents.charAt(0)=='y' || parents.charAt(0)=='Y') status=true; else status=false; } } //calculates total monthly costs by dividing the amount //of money the user has (payInput) by 3.75 (number of months //in a school semester) and substracts this value from //the total cost of rent and tuition. (tuition is calculated //on a per month basis, or divided by 4) public void calcTotalCost(){ totalCost=(payInput/3.75)-(rentExpenses + tuition/4); } //The display method displays the data entered into a clear //and concise dialog box public void display(){ String statusText; if(getStatus()==true) statusText="true"; else statusText="false"; JOptionPane.showMessageDialog(null, "Your total expenses per month are: "+ getTotalCost()+" Your tuition is: "+getTuition()+" Your rent "+ "is: "+getRent()+" Your amount entered for the payment method is"+ " "+getPayment()+" Residing with your parents: "+statusText); } //*****************************Mutator methods********************************* public void setPay(int num){ pay=num; } public void setRent(double ren){ while(ren
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