Question

In: Computer Science

reate a C# program. -Create 5 variables as decimals: Count, pricce, subtotal, tax, and total -Use...

reate a C# program.

-Create 5 variables as decimals: Count, pricce, subtotal, tax, and total

-Use a do while loop. If the price is not -1, the loop continues.

Show count number (ie: Item 1, Item 2, Item 3...)

Enter price

Get subtotal

Increase count

-Calculate tax(0.035%) and total

Show total count, subtotal, tax,and total

Output:

Item1: $2.00

Item2:: $3.00

Item3: $1.00

Item4: $-2 (Note: A negative number will not be substracted. It will only be ignored)

There are 3 Items in this order (This is the total count)

Subtotal: $6.00

Tax 0.035: $0.21

Total: $6.21

Solutions

Expert Solution

using System.IO;using System;
class Program
{
static void Main(string[] args)
{
int a=-1; double count=0;double price=-1; double subtotal=0; double tax=0;double total=0;
do
{
if(price >0){
Console.WriteLine("value of a: {0:R}", price);
count=count+1;total=total+1;
}
string temp;int temp2;
Console.WriteLine("Enter item {0:R}", count+1);;
temp = System.Console.ReadLine();
if (double.TryParse(temp, out price))
price = price;
}
while (price > -1);
Console.WriteLine("Total items {0:R}", count);
Console.WriteLine("Total price of items {0:R}", total);
tax=total*10;
Console.WriteLine("Tax of all items(10% assumed) {0:R}",tax );
subtotal=total+tax;
Console.WriteLine("Sub total of all items {0:R}", subtotal);
}
}


Related Solutions

C LANGUAGE ONLY Write a C program to count the total number of duplicate elements in...
C LANGUAGE ONLY Write a C program to count the total number of duplicate elements in an array. Enter the number of elements to be stored in the array: 3 Input 3 elements in the arrangement: element [0]: 5 element [1]: 1 element [2]: 1 Expected output: The total number of duplicate elements found in the array is: 1
1. Create a console program in C#, * Create a class: "Student.cs" * Add 3 variables:...
1. Create a console program in C#, * Create a class: "Student.cs" * Add 3 variables: StudentName (string), SchoolYear (int), YearsUntilGraduation(int) * Method YTK() = 12 - SchoolYear; 2. Main *Enter name *Enter age *You will attend school:____ years before graduating.
Create a C++ program that consists of the following: In maincreate the following three variables:...
Create a C++ program that consists of the following: In main create the following three variables: A char named theChar A double named theDouble An int named theInt Fill each of these variables with data taken as input from the keyboard using a single cin statement. Perform the following task on each variable: Increment theChar by one Decrement theDouble by two Square theInt This should be done on separate lines. Output the value of each variable to the screen on...
2. [50] Write a C program to count the total number of commented characters and words...
2. [50] Write a C program to count the total number of commented characters and words in a C file taking both types of C file comments (single line and block) into account.
write a simple program to demonstrate the use of static type of variables in c++... use...
write a simple program to demonstrate the use of static type of variables in c++... use comments to explain plz
Using C++ language, create a program that uses a struct with array variables that will loop...
Using C++ language, create a program that uses a struct with array variables that will loop at least 3 times and get the below information: First Name Last Name Job Title Employee Number Hours Worked Hourly Wage Number of Deductions Claimed Then, determine if the person is entitled to overtime and gross pay. Afterwards, determine the tax and net pay. Output everything to the screen. Use functions wherever possible. Bonus Points: Use an input file to read in an unknown...
Problems create a C++ program that will do the followings - define 3 double variables x,...
Problems create a C++ program that will do the followings - define 3 double variables x, y, z - calculate the value of y as the following formula: y = 2*x*x+4*x+5 and print x and y; - assign a new value to x: x=5.6 - calculate the value of z as the following formula z = (y*y)/4 + (x*x)/5 - print x, y,x
In C++, Create a program that can try out every possible logical combination of the variables...
In C++, Create a program that can try out every possible logical combination of the variables A, B, and C, and determine which combinations will yield a true statement. Take note that there are eight different possible combinations of the three variables. Make certain you test all eight of the combinations. (1) (A and B) or (A and C) (2) (A and C) and (B and !C) (3) (A or B) and !(B or C) (4) (A or (!A and...
C++ Create a program that use the linkedbag 3. Develop a program to maintain a list...
C++ Create a program that use the linkedbag 3. Develop a program to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services: • Add a new assignment. • Remove an assignment. • Provide a list of the assignments in the order they were assigned. • Find the assignment(s) with the earliest...
In C, 1) Create variables for: your first and last name total round trip to school...
In C, 1) Create variables for: your first and last name total round trip to school and home (assuming you don't live on campus - make it your hometown). cost of gas 2) Create a program that will: output your first name and your total miles driven for the week. output your last name with the total costs per week
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT