예제 #1
0
        static void Main() //testing routine
        {
            string s = UIF.PromptLine("Enter a line: ");

            Console.WriteLine("Reversed:");
            PrintReversed("\n" + s);
        }
예제 #2
0
		public static void Main (string[] args)
		{
			double balance = UIF.PromptDouble ("Please enter initial balance: ");
			double percentage = UIF.PromptDouble ("Please enter a percentage as a decimal: ");
			double desired_balance = UIF.PromptDouble ("Please enter desired balance: ");
	Console.WriteLine("The years to earn {0} is {1}.", desired_balance, BankAccount(balance, percentage, desired_balance);
		}
예제 #3
0
        static double findAverage(double numGrades)
        {
            double gradeTotal = 0;
            double average    = 0;

            for (int i = 0; i < numGrades; i++)
            {
                if (i == 0)
                {
                    gradeTotal += UIF.PromptDouble("Please enter your first grade: ");
                }
                else if (i == numGrades - 1)
                {
                    gradeTotal += UIF.PromptDouble("Please enter your last grade: ");
                }
                else
                {
                    gradeTotal += UIF.PromptDouble("Please enter your next grade: ");
                }
            }

            if (numGrades != 0)
            {
                average = (gradeTotal / numGrades);
            }
            else
            {
                average = 1;
            }

            return(average);
        }
예제 #4
0
        public static void Main(string[] args)
        {
            int rows = UIF.PromptInt("Please enter how many rows you want: ");
            int cols = UIF.PromptInt("Please enter how many columns you want: ");

            arrayMaker(rows, cols);
        }
예제 #5
0
        /// Prompt the user with a question; Return true of false.
        /// Allow certain starting characters for true (t, y) and
        /// others for false (f, n), and repeat until the response
        /// is in one of these groups.
        static Boolean Agree(string question)
        {
            int done = 0;

            question = UIF.PromptLine("Do you understand? Use 'y' or 'n'." + "\n");

            while (done == 0)
            {
                string res = question.ToLower();

                if (res.Length == 0)
                {
                    res = UIF.PromptLine("Please enter a response. Use 'y' or 'n'." + "\n");
                    return(false);
                }
                else if ((res != "y") || (res != "n"))
                {
                    res = UIF.PromptLine("Try again, we didn't understand your request. Use 'y' or 'n'." + "\n");
                }

                if (res == "y")
                {
                    done = 1;
                    return(true);
                }
                else if (res == "n")
                {
                    done = 1;
                    return(false);
                }
            }
            return(true);
        }
예제 #6
0
        static void Main()
        {
            int age        = UIF.PromptInt("Please enter the age: ");
            int citizenNum = UIF.PromptInt("Please enter Citizenship length: ");

            Console.WriteLine("The person can be: {0}", congressCheck(age, citizenNum));
        }
예제 #7
0
파일: sign.cs 프로젝트: the872/comp170
        static void Main()
        {
            posNegZero(10);
            int a = UIF.PromptInt("Enter an integer: ");

            Console.WriteLine(posNegZero(a));
        }
예제 #8
0
        static void Main()
        {
            int a = UIF.PromptInt("Please Enter an Integer: ");
            int b = UIF.PromptInt("Please Enter another Integer: ");

            Console.WriteLine(QuotientString(a, b));
        }
예제 #9
0
        static void Main()
        {
            int    age     = UIF.PromptInt("Enter your age ");
            int    citizen = UIF.PromptInt("Enter how many years you have been a citizen: ");
            string ans     = checkGraduation(age, citizen);

            Console.WriteLine(ans);
        }
예제 #10
0
        static void DoRemainder()
        {
            int num     = UIF.PromptInt("Enter integer: ");
            int divisor = UIF.PromptInt("Enter divisor: ");
            int r       = Remainder(num, divisor);

            Console.WriteLine("Remainder is " + r);
        }
예제 #11
0
        static void Main()
        {
            double hours = UIF.PromptDouble("Enter hours worked: ");
            double wage  = UIF.PromptDouble("Enter dollars paid per hour: ");
            double total = CalcWeekWages(hours, wage);

            Console.WriteLine("Wages for {0} hours at {1:F2} per hour are {2:F2}.", hours, wage, total);
        }
예제 #12
0
파일: savings.cs 프로젝트: the872/comp170
        static void Main()
        {
            double x = UIF.PromptDouble("Please enter your starting amount: ");
            double y = UIF.PromptDouble("Please enter your rate (ex. '.04'): ");
            double z = UIF.PromptDouble("Please enter your desired amount: ");

            Compound(x, y, z);
        }
예제 #13
0
        public static void Main(string[] args)
        {
            string input = UIF.PromptLine("Please enter a string:");

            ShowLength(input);
            SentenceType();
            LastFirst1();
            LastFirst2();
        }
예제 #14
0
        public static void LastFirst1()
        {
            string input3 = UIF.PromptLine("Please enter a name:");
            int    space  = input3.IndexOf(" ");
            string first  = input3.Substring(0, space);
            string last   = input3.Substring(space);

            Console.WriteLine("{0}, {1}", last, first);
        }
예제 #15
0
        static void Main()
        {
            int    hours = UIF.PromptInt("Enter total amount of credits: ");
            string ans   = totalCredits(hours);

            Console.WriteLine(
                "{0} have enough credits to graduate.",
                ans);
        }
예제 #16
0
        public static void Main()
        {
            Console.WriteLine(SumProblemString(2, 3));
            Console.WriteLine(SumProblemString(12345, 53579));
            int a = UIF.PromptInt("Enter an integer: ");                  //NEW
            int b = UIF.PromptInt("Enter another integer: ");             //NEW

            Console.WriteLine(SumProblemString(a, b));
        }
예제 #17
0
 }                       // end chunk
 
 static void Main()  // rest same as in Wages1.cs
 {
    double hours = UIF.PromptDouble("Enter hours worked: ");
    double wage = UIF.PromptDouble("Enter dollars paid per hour: ");
    double total = CalcWeeklyWages(hours, wage);
    Console.WriteLine(
       "Wages for {0} hours at ${1:F2} per hour are ${2:F2}.",
       hours, wage, total);
 }
예제 #18
0
        static void Main()
        {
            double weight = UIF.PromptDouble("How many pounds does your suitcase weigh? ");

            if (weight > 50)
            {
                Console.WriteLine("There is a $25 charge for luggage that heavy.");
            }
            Console.WriteLine("Thank you for your business");
        }
예제 #19
0
        static void Main()
        {
            double hours = UIF.PromptDouble("Enter hours worked: ");
            double wage  = UIF.PromptDouble("Enter dollars paid per hour: ");
            double total = CalcWeeklyWages(hours, wage); //before chunk2

            Console.WriteLine(
                "Wages for {0} hours at ${1:F2} per hour are ${2:F2}.",
                hours, wage, total);
        }                                              //after chunk2
        static void Main() //testing routine
        {
            int n = UIF.PromptInt("Enter a positive integer: ");

            Console.WriteLine(n);
            Console.WriteLine("One jump from {0} is {1}.", n, Jump(n));
            Console.WriteLine("Sequence until 1:");
            PrintStrangeSequence(n);
            Console.WriteLine("{0} elements in the sequence.",
                              CountStrangeSequence(n));
        }
예제 #21
0
        /// Return an int entered by the user.  Catch input
        /// errors, and keep promping the user until a
        /// legal entry is made.  Return the corresponding int.
        static int PromptInt(string prompt)
        {         //FIX so loops until legal
            int ans = 0;

            while (IsIntString(prompt) != true)
            {
                string nStr = UIF.PromptLine(prompt).Trim();
                ans = int.Parse(nStr);
            }
            return(ans);
        }
예제 #22
0
        /// Return a double entered by the user.  Catch input
        /// errors, and keep promping the user until a legal
        /// decimal entry is made.  Return the corresponding double.  .
        static double PromptDouble(string prompt)
        {          //FIX so loops until legal
            double ans = 0.00;

            while (IsDecimalString(prompt) != true)
            {
                string nStr = UIF.PromptLine(prompt).Trim();
                ans = double.Parse(nStr);
            }
            return(ans);
        }
예제 #23
0
        // end of function chunk
        static void Main()
        {
            Console.WriteLine("Your letter grade is {0}.", letterGrade(88));
            Console.WriteLine("Your letter grade is {0}.", letterGrade(90));
            Console.WriteLine("Your letter grade is {0}.", letterGrade(78));
            Console.WriteLine("Your letter grade is {0}.", letterGrade(68));
            Console.WriteLine("Your letter grade is {0}.", letterGrade(58));
            double g = UIF.PromptDouble("Enter a numerical grade: ");

            Console.WriteLine("Your letter grade is {0}.", letterGrade(g));
        }
        //  new chunk
        /// Prompt the user to obtain an int until the response is in the
        /// range [lowLim, highLim].  Then return the int in range.
        static int PromptIntInRange(string prompt, int lowLim, int highLim)
        {
            int number = UIF.PromptInt(prompt);

            while (number < lowLim || number > highLim)
            {
                Console.WriteLine("{0} is out of range!", number);
                number = UIF.PromptInt(prompt);
            }
            return(number);
        }
예제 #25
0
        /// Return a whole number.  Catch input
        /// errors, and keep prompting the user until
        /// a legal entry is made, and return
        /// the corresponding int.  Trim extra whitespace.
        static int PromptWhole(string prompt)
        {
            string userinput = UIF.PromptLine(prompt);
            bool   digitTest = IsDigits(userinput);

            while (digitTest == false)
            {
                userinput = UIF.PromptLine("Enter an integer: ");
                digitTest = IsDigits(userinput);
            }
            return(int.Parse(userinput));
        }
예제 #26
0
        static void addOne()
        {
            int sum = 0;
            int one = UIF.PromptInt("Enter one number at a time and I will add them up." + "\n" + "When you are done, enter '0'." + "\n");

            while (one != 0)
            {
                sum += one;
                one  = UIF.PromptInt("Please enter another number. Remember to end press '0'." + "\n");
            }
            Console.Write("Your total is: " + sum + ".");
        }
예제 #27
0
파일: array_lab.cs 프로젝트: the872/comp170
 //ReadInts chunk
 ///  Prompt the user to enter n integers, and
 ///  return an array containing them.
 ///  Example:  ReadInts("Enter values", 3) could generate the
 ///  Console sequence:
 ///      Enter values (3)
 ///      1: 5
 ///      2: 7
 ///      3: -1
 ///  and the function would return an array containing {5, 7, -1}.
 static int[] ReadInts(string prompt, int n)
 {
     int[] num;
     num = new int[(n - 1)];
     Console.WriteLine(prompt + " (" + n + ")");
     for (int i = 0; i < n; i++)
     {
         int ans = UIF.PromptInt((i + 1) + ": ");
         num [i] = ans;
     }
     return(num);            // so stub compiles
 }
예제 #28
0
        public static void Main(string[] args)
        {
            int i, total = 0;

            // what to make the condition?
            while (i != 0)
            {
                int sum = UIF.PromptInt("Please enter an integer: ");
                total += sum;
                i++;
            }
        }
예제 #29
0
        public static void Main(string[] args)
        {
            int earned_credits = UIF.PromptInt("How many credits have you earned? ");

            if (earned_credits >= 120)
            {
                Console.WriteLine("You have earned the required amount of credits needed for graduations/nHurrary!");
            }
            else
            {
                Console.WriteLine("You are not ready to graduate.");
            }
        }
예제 #30
0
        static void Main() //testing routine
        {
            string maybeNum = UIF.PromptLine("Enter a number, maybe: ");

            Console.WriteLine("{0}: Is it a legal int? {1}.  A double? {2}",
                              maybeNum, IsIntString(maybeNum), IsDecimalString(maybeNum));
            int n = PromptInt("Enter a score: ");

            Console.WriteLine("Your score is {0}.", n);
            double x = PromptDouble("Enter a decimal number: ");

            Console.WriteLine("Your number is {0}.", x);
        }