Advertisement
MoNoLidThZ

RocketLaunchApp

Apr 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace RocketLaunchApp {
  8.     class Program {
  9.         static void Main(string[] args) {
  10.             int Temperature = 0;
  11.             string GoOrNot = "n";
  12.             string Sky = "p";
  13.             //State 1: Enter temp
  14.             bool valid = false;
  15.             while (!valid) {
  16.                 Console.Write("Enter temperature: ");
  17.                 valid = Int32.TryParse(Console.ReadLine(), out Temperature)
  18.                     && Temperature > 0;
  19.             }
  20.             //State 2: Enter System Status
  21.             valid = false;
  22.             while (!valid) {
  23.                 Console.Write("All system go (Y/N): ");
  24.                 GoOrNot = Console.ReadLine().ToLower();
  25.                 if (GoOrNot == "y" || GoOrNot == "n") {
  26.                     valid = true;
  27.                 }
  28.             }
  29.             //State 3: Enter Sky Status
  30.             valid = false;
  31.             while (!valid) {
  32.                 Console.Write("Sky confirm (P,C,R,T): ");
  33.                 Sky = Console.ReadLine().ToLower();
  34.                 if (Sky == "p" || Sky == "c" || Sky == "r" || Sky == "t") {
  35.                     valid = true;
  36.                 }
  37.             }
  38.            
  39.             //Summarize up
  40.             bool canLaunch = true;
  41.             if(Temperature > 90 || Temperature < 60) {
  42.                 canLaunch = false;
  43.             }
  44.             if(GoOrNot == "n") {
  45.                 canLaunch = false;
  46.             }
  47.             if (Sky == "r" || Sky == "t") {
  48.                 canLaunch = false;
  49.             }
  50.             if (canLaunch) {
  51.                 Console.WriteLine("Launch Now!!");
  52.             } else {
  53.                 Console.WriteLine("Do Not Launch!!");
  54.             }
  55.             Console.ReadLine();
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement