Question

In: Computer Science

C# Tip Calculator. I can't figure the code out for this assignment can I get some...

C# Tip Calculator. I can't figure the code out for this assignment can I get some help

For this assignment, you'll create a simple tip calculator. Expected program flow:

  1. Ask the user for the bill total.
  2. Ask the user for the tip percent.
  3. Print the final output in the following format when the user enters 10 and 15 for the first two prompts:
    Total for bill $10.00 with a 15% tip is $11.50 
    

Note that the money values should be formatted using the correct currency, prefixed with the $ and rounded to 2 decimal places.

Solutions

Expert Solution

Here Iam providing the code and the output for the given problem

Code

Sample Output

Code

using System;
class Test{
static void Main() {
  
Console.WriteLine("Enter the bill total : "); //reading inputs from user
double TotalBill = double.Parse(Console.ReadLine());
Console.WriteLine("Enter the tip percentage : "); //reading the tip Percentage
double Percentage = double.Parse(Console.ReadLine());
double tip = TotalBill * (Percentage/100.0); //calculating the tip
double result = Math.Round((TotalBill + tip),2); //rounding to two decimal places
string res = result.ToString("0.00"); //adds trail zero if the result has 1 decimal place
Console.WriteLine("Total for bill $"+TotalBill+" with a "+Percentage+"% tip is $"+res);
  
  
}
}


Related Solutions

I'm trying to make this C++ loan calculator but I can't get the program to output...
I'm trying to make this C++ loan calculator but I can't get the program to output what I need. For instance I know the formula is right and when I enter 100000 1.5 20 as my cin variables I should get 482.55 but I get 1543.31. What am I not seeing as the issue? Also this should cout only 2 decimal places right? I'm not allowed to alter the #include and add any fixed setprecision. This is what I have....
Would anyone know how to code this in SQL? I can't quite figure it out. The...
Would anyone know how to code this in SQL? I can't quite figure it out. The following drop command is inserted for convenience so that if you need to recompile your code, it will drop the table DROP TABLE Orders Cascade constraints DROP TABLE OrderLine CASCADE CONSTRAINTS; -- CREATE TABLE Orders ( ordernum INTEGER PRIMARY KEY, priority CHAR(10) NOT NULL, cost INTEGER NOT NULL, /* IC1: The priority is one of: high, medium, or low */ >> /* IC2: The...
This is my C language code. I have some problems with the linked list. I can't...
This is my C language code. I have some problems with the linked list. I can't store the current. After current = temp, I don't know how to move to the next node. current = current-> next keeps making current into NULL. #include #include #include #include struct node{int data; struct node *next;}; int main() {     struct node *head, *current, *temp, *trash;     srand(time(0));     int randNumber = rand()%51;     if(randNumber != 49)     {         temp = (struct node*)malloc(sizeof(struct node));         current = (struct node*)malloc(sizeof(struct node));...
Murach Android tip calculator event handling assignment
Murach Android tip calculator event handling assignment
I am supposed to map out the following and can't figure out how to do it!...
I am supposed to map out the following and can't figure out how to do it! Can somebody help? The experiment has to do with determining the simplest formula of potassium chlorate and to determine the original amount of potassium chlorate in a potassium chlorate-potassium chloride mixture by measuring the oxygen lost from decomposition. The chemical reaction is 2KClO3(s) ------> 2KCL(s) + 3 O2(g) I am supposed to map out 1. Mass of oxygen lost in the first part 2....
Hi, I can't figure out this question in excel, can someone please show me the excel...
Hi, I can't figure out this question in excel, can someone please show me the excel formulas to input in order to solve for part A and B please!!!! The following table contains closing monthly stock prices for Oracle Corporation (ORCL), Microsoft Corporation (MSFT), and NVidia (NVDA) for the first half of 2017. Ticker 6/30/2017 5/31/2017 4/30/2017 3/31/2017 2/28/2017 1/31/2017 ORCL 50.14 45.39 44.96 44.61 42.59 40.11 MSFT 68.93 69.84 68.46 65.86 63.98 64.65 NVDA 144.56 144.35 104.3 108.93 101.48...
Can you use phenolphthalein to titrate a colored solution? Explain please! I can't figure this out.
Can you use phenolphthalein to titrate a colored solution? Explain please! I can't figure this out.
I need to create a monthly loan Calculator in C++. I know the formula but can't...
I need to create a monthly loan Calculator in C++. I know the formula but can't figure out what's wrong with my code. Any clarification would be appreciated! // Only add code where indicated by the comments. // Do not modify any other code. #include <iostream> #include <cmath> using namespace std; int main() {    // ---------------- Add code here --------------------    // -- Declare necessary variables here              --        int years = 0; //n     int LoanAmount =...
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...
I am struggling with this assignment. I can't get the program to run when I enter...
I am struggling with this assignment. I can't get the program to run when I enter a number with the $ symbol followed by a number below 10. any help would be greatly appreciated. Create a program named Auction that allows a user to enter an amount bid on an online auction item. Include three overloaded methods that accept an int, double, or string bid. Each method should display the bid and indicate whether it is over the minimum acceptable...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT