fork download
  1. using System;
  2.  
  3. public class GreenvilleRevenueGUI
  4. {
  5. public static void Main()
  6. {
  7. //number of contestants
  8. int PC;
  9. int CC;
  10. int DPC; //doubled PC
  11. int L = 0;
  12.  
  13. Console.WriteLine("Each contestant must pay $25."); //displayed text and instructions
  14.  
  15. while (L < 1)
  16. {
  17. Console.WriteLine("How many contestants entered last year?");
  18. PC = Convert.ToInt32(Console.ReadLine()); //input number of contestants here
  19.  
  20. //PC = 31;
  21. if (PC < 0 || PC > 30)
  22. {
  23. Console.WriteLine("Invalid amount of contestants.");
  24. }
  25. else
  26. {
  27. L++;
  28. }
  29. }
  30.  
  31. while (L < 2)
  32. {
  33. Console.WriteLine("How many contestants entered this year?");
  34. CC = Convert.ToInt32(Console.ReadLine()); //input number of contestants here
  35.  
  36. if (CC < 0 || CC > 30)
  37. {
  38. Console.WriteLine("Invalid amount of contestants.");
  39. }
  40. else
  41. {
  42. L++;
  43. }
  44. }
  45.  
  46. PC = 15;
  47. CC = 12;
  48.  
  49. //getting totals
  50. Console.WriteLine("Amount made last year:");
  51. Console.Write(PC + " X 25 = $"); //Using "write" instead of "writeline" so it doesn't go to the next line.
  52. PC = PC * 25; //figures out the total
  53. Console.WriteLine(PC); //displays total
  54. Console.WriteLine("Amount made this year:");
  55. Console.Write(CC + " X 25 = $"); //Using "write" instead of "writeline" so it doesn't go to the next line.
  56. CC = CC * 25; //figures out the total
  57. Console.WriteLine(CC); //displays total
  58.  
  59. DPC = PC * 2; //just to make it easier to check for double
  60.  
  61. if (CC > PC)
  62. {
  63. if (CC > DPC) //the double check is place here since CC has to be bigger than PC, so putting it here not only makes the code check for less things at once, but it won't display the text for two different conditions if CC is bigger than DPC
  64. {
  65. Console.WriteLine("The competition is more than twice as big this year!");
  66. }
  67. else
  68. {
  69. Console.WriteLine("The competition is bigger than ever!");
  70. }
  71. }
  72. else if (CC < PC) //would normally make it just an else, but since it's check for lower and there's no condition for equal
  73. {
  74. Console.WriteLine("A tighter race this year! Come out and cast your vote!");
  75. }
  76.  
  77. }
  78. }
  79.  
Success #stdin #stdout 0.03s 15008KB
stdin
Standard input is empty
stdout
Each contestant must pay $25.
How many contestants entered last year?
How many contestants entered this year?
Amount made last year:
15 X 25 = $375
Amount made this year:
12 X 25 = $300
A tighter race this year!  Come out and cast your vote!