Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform.

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