Question: 1) draw flowchart using this code as (pDF version) import java.util.Scanner; public class ReturnTeax { public static void main(String args[]) { Scanner sc = new
1) draw flowchart using this code as (pDF version)
import java.util.Scanner; public class ReturnTeax { public static void main(String args[]) { Scanner sc = new Scanner(System.in); double theIncome; double rateHourly; int consultingTime; double theCharges; int timediff; while(true) { System.out.println(" "); theIncome = getYearlytheIncome(sc); if(theIncome == -999) break; rateHourly = getrateHourly(sc); consultingTime = getConsultingTime(sc); if(theIncome < 0 || rateHourly <0 || consultingTime < 0) { System.out.println("Invalid input, tryagain."); continue; } System.out.println(" The billing amount is: "+gettheCharges(consultingTime, rateHourly, istheIncomeLess(theIncome))); } } public static double getrateHourly(Scanner sc) { System.out.println("Enter rate(hourly): "); return sc.nextDouble(); } public static double getYearlytheIncome(Scanner sc) { System.out.println("Enter the income, yearly (-999 to end): "); return sc.nextDouble(); } public static int getConsultingTime(Scanner sc) { System.out.println("Enter consulting time: "); return sc.nextInt(); } public static boolean istheIncomeLess(double theIncome) { return theIncome <= 25000; } public static double gettheCharges(int totalConsultingTime, double rateHourly, boolean islowertheIncome) { double theCharges=0; if(islowertheIncome) { if(totalConsultingTime <=30) theCharges = 0; else { totalConsultingTime = totalConsultingTime - 30; rateHourly = 0.4*rateHourly; theCharges = rateHourly * totalConsultingTime / 60; } } else { if(totalConsultingTime <= 20) { theCharges = 0; } else { totalConsultingTime = totalConsultingTime - 20; rateHourly = rateHourly * 0.7; theCharges = rateHourly * totalConsultingTime / 60; } } return theCharges; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
