Program no: 7

Create a billing machine that takes the cost of each item, number of items each and calculate total cost of purchase. It should keep asking for next item to enter until we press ‘n’ upon which it should give the total cost of purchase. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { int cost, n,totalcost=0; string key; do { Console.WriteLine("Enter the cost of item:"); cost = int.Parse(Console.ReadLine()); Console.WriteLine("enter the number of items:"); n = int.Parse(Console.ReadLine()); Console.WriteLine("do you have any items to enter:"); key = Console.ReadLine(); totalcost = totalcost + (cost * n); }while(key!="n"); Console.WriteLine("total cost is {0}", totalcost); Console.ReadLine(); } } }

Output:

Sign up to vote on this title
UsefulNot useful