Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp210
- {
- class Program
- {
- static void Main()
- {
- decimal desiredAmount = decimal.Parse(Console.ReadLine());
- decimal totallyCollected = 0.00M;
- string command = "";
- while(command != "End" && totallyCollected < desiredAmount)
- {
- command = Console.ReadLine();
- if(command == "End" || totallyCollected >= desiredAmount)
- {
- break;
- }
- decimal incomingAmount;
- bool commandIsDecimal = decimal.TryParse(command, out incomingAmount);
- if(commandIsDecimal)
- {
- totallyCollected += incomingAmount;
- }
- }
- if(totallyCollected >= desiredAmount)
- {
- Console.Write("We collected the entire amount of {0}.", totallyCollected);
- }
- else
- {
- Console.Write("We collected {0} - {1} less than the necessary amount.", totallyCollected, desiredAmount - totallyCollected);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement