Question

In: Computer Science

Tip Calculator Instructions For this project you are to create a tip calculator that will take...

Tip Calculator Instructions

For this project you are to create a tip calculator that will take a decimal/or non decimal amount and calculate the different tip values of that amount:

10% 15% 20%

And display them appropriately. The values will be set to two decimal places. If you have an empty value, then a message will display informing the user of such. When the device is rotated the error message or tip information must continue to be displayed.

in Android/Java

Solutions

Expert Solution

Tip Calculator Using Java Program

In this program, accepting bill amount as user input and checking the user entered input is correct or not. If not display the proper message to the user. Finding the 10%, 15% and 20% of the bill amount as tip amount and also find the total amount.

Scanner is used for taking input from the user.

Here, if ...else is used for checking the user input.

%.2f is used for displaying the output in two decimal places.

Program in Java
import java.util.Scanner;
public class Main
{
   public static void main(String[] args) {
  
   //input bill amount from user
       Scanner scan = new Scanner(System.in);
       System.out.print("Bill Amount: ");
   double billAmt = scan.nextDouble();
  
   if(billAmt==0){
  
   System.out.printf("Bill Amount cannot be zero.");
   }else if(billAmt<0){
  
   System.out.printf("Bill Amount cannot be negative.");
   }
   else{
  
   //calculate the tip amount of 10%, 15% and 20% of bill amount And Finding total amount.
   //%.2f => values will be set to two decimal places
       System.out.printf("\nTip Amount of 10%% = %.2f and Bill Amount =%.2f", (billAmt*0.1),(billAmt + (billAmt*0.1)));
System.out.printf("\nTip Amount of 15%% = %.2f and Bill Amount =%.2f", (billAmt*0.15),(billAmt + (billAmt*0.15)));
System.out.printf("\nTip Amount of 20%% = %.2f and Bill Amount =%.2f", (billAmt*0.2),(billAmt + (billAmt*0.2)));
  
   }
   }
}
/* ---------------END-------------- */


Related Solutions

In this project you will create a basic console based calculator program. The calculator can operate...
In this project you will create a basic console based calculator program. The calculator can operate in two modes: Standard and Scientific modes. The Standard mode will allow the user to perform the following operations: (+, -, *, /) add, subtract, multiply, and divide The Scientific mode will allow the user to perform the same functionality as the Standard add, subtract, multiply, and divide (+, -, *, / ) plus the following: sin x, cos x, tan x. (sin x,...
Murach Android tip calculator event handling assignment
Murach Android tip calculator event handling assignment
Modify the Tip Calculator app to allow the user to enter the number of people in...
Modify the Tip Calculator app to allow the user to enter the number of people in the party. Calculate and display the amount owed by each person if the bill were to be split evenly among the party members. Code: ----------------TipCalculator.java----------------------- import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class TipCalculator extends Application { @Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("TipCalculator.fxml")); Scene scene = new Scene(root); // attach scene graph to scene...
How can I configure the button in this tip calculator to calculate the total using the...
How can I configure the button in this tip calculator to calculate the total using the entires for the bill and tip percentage? I'm using Visual Studio 2019 Xamarin.Forms Main.Page.xaml <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Accomplish_2.MainPage" BackgroundColor="Gray" Padding="5"> <StackLayout> <!-- Place new controls here --> <Label Text="Tip Calculator" HorizontalOptions="Center" VerticalOptions="Center" FontSize="Title" FontAttributes="Bold"/> <BoxView BackgroundColor="LightPink" HeightRequest="3"></BoxView>    <Entry Placeholder="Bill Total" Keyboard="Numeric" x:Name="billTotal"></Entry>    <Entry Placeholder="Tip Percentage" Keyboard="Numeric" x:Name="tipPercent"></Entry> <Button Text="Calculate" Clicked="Button_Clicked"></Button>    </StackLayout> </ContentPage> Everything above...
Please follow the instructions and solve it by c++ Close the project and create a new...
Please follow the instructions and solve it by c++ Close the project and create a new one called 'Lab0-Part3' with the same options as in the previous step. Write a C++ program that does the following: Creates a 100-element array, either statically or dynamically Fills the array with random integers between 1 and 100 inclusive Then, creates two more 100-element arrays, one holding odd values and the other holding even values. Prints both of the new arrays to the console.
Instructions to solve the problem: You are required to use a financial calculator or spreadsheet (Excel)...
Instructions to solve the problem: You are required to use a financial calculator or spreadsheet (Excel) to solve the problem related to the cost of capital. You are required to show the following 3 steps for the problem. (i) Describe and interpret the assumptions related to the problem. (ii) Apply the appropriate mathematical model to solve the problem. (iii) Calculate the correct solution to the problem. Submit all answers as percentages and round to two decimal places. Problem: Cosa Nostra...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the provided...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the provided capital budgeting problem (sample questions and solutions are provided for guidance). Problem: Windrunner Corp. is considering a new machine that requires an initial investment of $800,000 installed and has a useful life of 10 years. The expected annual after-tax cash flows for the machine are $120,000 during the first 5 years, $150,000 during years 6 through 8 and $180,000 during the last two years....
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the following...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the following capital budgeting problem (sample questions and solutions are provided for guidance): Kingston Corp. is considering a new machine that requires an initial investment of $520,000 installed, and has a useful life of 8 years. The expected annual after-tax cash flows for the machine are $76,000 during the first 3 years, $87,000 during years 4 through 6 and $92,000 during the last two years. (i)...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the following...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the following capital budgeting problem (sample questions and solutions are provided for guidance): Windrunner Corp. is considering a new machine that requires an initial investment of $800,000 installed, and has a useful life of 10 years. The expected annual after-tax cash flows for the machine are $120,000 during the first 5 years, $150,000 during years 6 through 8 and $180,000 during the last two years. (i)...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the problems...
Instructions: You are required to use a financial calculator or spreadsheet (Excel) to solve the problems (provided on page 4) related to risk and return characteristics and stock/bond valuation. You are required to show the following three steps for each problem (sample problems and solutions are provided for guidance): (i) Describe and interpret the assumptions related to the problem. (ii) Apply the appropriate mathematical model to solve the problem. (iii) Calculate the correct solution to the problem. A company’s stock...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT