Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- int numOfItems = int.Parse(Console.ReadLine());
- double totalBudget = 0;
- double itemsTotalPrice = 0;
- for(int i = 0; i <= numOfItems; i++)
- {
- String item = Console.ReadLine();
- double itemPrice = int.Parse(Console.ReadLine());
- int itemCount = int.Parse(Console.ReadLine());
- itemsTotalPrice = itemPrice * itemCount;
- totalBudget += itemsTotalPrice;
- if (itemCount > 1)
- {
- item += "s";
- Console.WriteLine("Adding {0} {1} to cart.", itemCount, item);
- }
- }
- if (totalBudget <= budget)
- {
- Console.WriteLine("Subtotal: ${0}", totalBudget);
- Console.WriteLine("Money left:${0}", totalBudget - budget);
- }
- else if (totalBudget > budget)
- {
- Console.WriteLine("Not enough.We need ${0}more.", totalBudget);
- Console.WriteLine("Money left:${0}", budget - totalBudget);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment