The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
It's C# code for an application that computes the total due for purchases. Any help would be great so I can finish this off tonight.
In the final program it must ask for the price of the item. "What is the amount of the item?"
Once the price is entered it will then ask "Do you want to enter another item? Y or N
Then ask the price of the item again. All while keeping track of the price of each item for the final purchase price.Â
Â
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter6Homework1
{
   class Ch6Program1
   {
       static void Main(string[] args)
       {
           int items, cost, tax, total;
           int shipping = 0;
           bool quitProgram = false;
           //Display Info and Instructions
           WriteLine("nThis application computed the total due for your purchases.");
           WriteLine("nIt will allow you to enter any number of purchase amounts.");
           WriteLine("When you are finished entering purchases, it displays the total due including sales tax and shipping costs.");
           //Determine to quit or keep entering prices
           while (quitProgram == false)
               if (quitProgram == false)
               {
                   WriteLine("Do you want to enter another item? Y  or N :");
                   break;
               }
               else if (quitProgram == true)
               {
                   WriteLine();
                   WriteLine("What is the amount of the item? ");
                   cost = Double.Parse(ReadLine());
           }
           //Calculates shipping cost
           while (items)
           {
               if (items <= 3)
                   shipping = 3.50;
               else if (items > 3 && <= 6)
                   shipping = 5.00;
               else if (items > 6 && <= 10)
                   shipping = 7.00;
               else if (items > 10 && <= 15)
                   shipping = 9.00;
               else (items > 15)
                       shipping = 10.00;
               return shipping;
           }
           //Calculates tax
           tax = cost * (7.75 / 100.0);
           return tax;
           //Cacluates total
           total = cost + shipping + tax;
           return total;
           //Displays results
           WriteLine("--------------------------------------");
           WriteLine("nItems total cost: $"{0:c2} + cost);
           WriteLine("nNumber of items:"{0} + items);
           WriteLine("nSales Tax:$ " { 0:c2} + tax);
           WriteLine("nShipping: $ "{ 0:c2} + shipping);
           WriteLine("--------------------------------------");
           WriteLine("nnGrand Total: $ "{ 0:c2} cost+tax+total);
       }
   }
}