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....
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...
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...
This is a question from Intro to Bayesian Statistics but I can't figure out what is...
This is a question from Intro to Bayesian Statistics but I can't figure out what is expected here. Derive the posterior distribution of obtaining heads in coin flips. The prior has p(θ = .25) = .25, p(θ = .50) = .50, and p(θ = .75) = .25. The data consist of a specific sequence of flips with 3 heads and 9 tails, so p(Data|θ) = θ^3 (1 − θ) ^9.
I can't figure out this math equation for "The Importance of the Price Elasticity of Demand:...
I can't figure out this math equation for "The Importance of the Price Elasticity of Demand: MC=P(1+(1/Ed)) My marginal cost(MC) is $50/month and that the price elasticity of demand (Ed) is -2.5, what price will maximize my firm's profits? $50=P(1+(1/-2.5))
What is the computations for the following answers? I can't figure this one out. The following...
What is the computations for the following answers? I can't figure this one out. The following information relates to Hudson City for its fiscal year ended December 31, 2017. • During the year, retailers in the city collected $1,700,000 in sales taxes owed to the city. As of December 31, retailers have remitted $1,100,000. $200,000 is expected in January 2018, and the remaining $400,000 is expected in April 2018. • On December 31, 2016, the Foundation for the Arts pledged...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT