Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Experience the ease of finding quick and accurate answers to your questions from professionals on our platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

Write a program that prompts the user to enter the hourly rate, the total consulting time, and whether the person has low income. The program should output the billing amount. Your program must contain a function that takes as input the hourly rate, the total consulting time, and a value indicating whether the person has low income. The function should return the billing amount. Your program may prompt the user to enter the consulting time in minutes.

Sagot :

Answer:

Explanation:

The following program was written in Java. It creates the function as requested and asks the user for all the values as inputs. No proper reason was given for asking for low income so I just added it as a yes or no print statement. The picture below shows the inputs and outputs of the program.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Hourly rate: ");

       double rate = in.nextDouble();

       System.out.println("Consulting Time in minutes: ");

       int consultingTime = in.nextInt();

       System.out.println("Low Income? y/n");

       String lowIncome = in.next().toLowerCase();

       String lowIncomeAnswer;

       if (lowIncome.charAt(0) == 'y') {

           lowIncomeAnswer = "Yes";

       } else {

           lowIncomeAnswer = "No";

       }

       System.out.println("Billing Amount: " + billing(rate, consultingTime, lowIncome));

       System.out.println("Low Income: " + lowIncomeAnswer);

   }

   public static double billing(double rate, int consultingTime, String lowIncome) {

       double timeHours = consultingTime / 60;

       double billing = rate * timeHours;

       return billing;

   }

}

View image sandlee09