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); }
static void Main() { posNegZero(10); int a = UIF.PromptInt("Enter an integer: "); Console.WriteLine(posNegZero(a)); }
static void Main() { int a = UIF.PromptInt("Please Enter an Integer: "); int b = UIF.PromptInt("Please Enter another Integer: "); Console.WriteLine(QuotientString(a, b)); }
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)); }
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); }
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); }
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)); }
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); }
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)); }
// 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); }
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 + "."); }
//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 }
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++; } }
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."); } }
/// Prompt the user to obtain an int until the response is in the /// range [lowLim, highLim]. Then return the int in range. /// Use the specified prompt, adding a reminder of the allowed range. static int PromptIntInRange(string prompt, int lowLim, int highLim) { string longPrompt = string.Format("{0} ({1} through {2}) ", prompt, lowLim, highLim); int number = UIF.PromptInt(longPrompt); while (number < lowLim || number > highLim) { Console.WriteLine("{0} is out of range!", number); number = UIF.PromptInt(longPrompt); } return(number); }
/// Prompt the user to obtain an int until the response is in the /// range [lowLim, highLim]. Then return the int in range. /// Use the specified prompt, adding a reminder of the allowed range. static int PromptIntInRange(string prompt, int lowLim, int highLim) { string longPrompt = string.Format("{0} ({1} through {2}) ", prompt, lowLim, highLim); // start chunk int number = UIF.PromptInt(longPrompt); while (number < lowLim || number > highLim) { Console.WriteLine("{0} is out of range!", number); // number = UIF.PromptInt(longPrompt); //OMITS repeated prompt! } return(number); } // past new chunk
public static void Main(string[] args) { int exams, labs, homework, projects, participation, weightsum; do { Console.WriteLine("Please enter the weights for the following"); exams = UIF.PromptInt("Exams: "); labs = UIF.PromptInt("Labs: "); homework = UIF.PromptInt("Homework: "); projects = UIF.PromptInt("Projects: "); participation = UIF.PromptInt("Participation: "); weightsum = exams + labs + homework + projects + participation; if (weightsum != 100) { Console.WriteLine("Please enter the weights again."); } } while (weightsum != 100); double ExamScore, LabScore, HomeworkScore, ProjectsScore, ParticipationScore; double number = UIF.PromptDouble("Please enter the number of grades for exams: "); ExamScore = exams * FindAverage("exams", number); double number1 = UIF.PromptDouble("Please enter the number of grades for labs: "); LabScore = labs * FindAverage("labs", number1); double number2 = UIF.PromptDouble("Please enter the number of grades for homework: "); HomeworkScore = homework * FindAverage("homework", number2); double number3 = UIF.PromptDouble("Please enter the number of grades for projects: "); ProjectsScore = projects * FindAverage("projects", number3); double number4 = UIF.PromptDouble("Please enter the number of grades for participation: "); ParticipationScore = participation * FindAverage("participation", number4); double sum2 = ExamScore + LabScore + HomeworkScore + ProjectsScore + ParticipationScore; double FinalScore = sum2 / 100.0; Console.WriteLine("Your grade in the class is {0}%.", FinalScore); Console.WriteLine("Your letter grade is {0}.", LetterGrade(FinalScore)); }
public static void Main(string[] args) { int number = UIF.PromptInt("Enter an integer: "); if (number > 0) { Console.WriteLine("Positive"); } else if (number == 0) { Console.WriteLine("0"); } else { Console.WriteLine("Negative"); } }
public static void Main(string[] args) { int years = UIF.PromptInt("How long have you lived in the US? "); int age = UIF.PromptInt("How old are you? "); if (age >= 25 && years >= 7) { Console.WriteLine("You are eligible to be a US Representative"); } else if (age >= 30 && years >= 9) { Console.WriteLine("You are elibible to be a US Senator and a US Representative."); } else { Console.WriteLine("You are not eligible for a US congress"); } }
public static void Main() { List <string> c = Comments(comments); int money = UIF.PromptInt(c[4]); if (money >= 50) { Console.WriteLine(c[5]); } else { Console.WriteLine(c[6]); } Player p = new Player(money); string z = "y"; while (z == "y") { string betting = UIF.PromptLine("Would you like to bet?"); p.betting = betting; if (betting == "betting") { int bet = UIF.PromptLine(c[7]); p.bet = bet; } string outcome = Play(); if (outcome == c[1]) { Console.WriteLine("OMG"); p.score += 1; p.money += prop.bet; } else if (outcome == c[2]) { //p.money -= prop.bet; Console.WriteLine("OMG"); } if (p.score > p.highScore) { p.highScore += 1; } z = UIF.PromptLine(c[8]); } }
static void Game() { int big = 0; int small = 1; int guesses = 0; big = UIF.PromptInt("What do you want the highest number to be?" + "\n"); Random r = new Random(); int secret = r.Next(small, big); int guess = UIF.PromptInt("Guess the number between " + small + " and " + big + "." + "\n"); bool right = false; bool playag = false; while (right != true) { guesses++; if (guess == secret) { playag = UIF.Agree("That's right!" + "\n" + "It took you " + guesses + " guesses." + "\n" + "Press 'y' to play again or 'q' to quit" + "\n"); right = true; } else if (guess > secret) { guess = UIF.PromptInt("A little lower!" + "\n"); } else if (guess < secret) { guess = UIF.PromptInt("A little higher!" + "\n"); } } if (playag == true) { Game(); } else { Environment.Exit(0); } }
// end bad chunk static void Main() { int n = UIF.PromptInt("Enter the largest number in the sum: "); Console.WriteLine("The sum of 1 through {0} is {1}.", n, SumToN(n)); }
public static void Main() { Console.WriteLine(PartofPlane( UIF.PromptInt("Integer X: "), UIF.PromptInt("Integer Y: "))); }
using System; namespace IntroCS { class quotient { static string QuotientString(int x, int y) { int ans = x / y; int remain = x % y; string sentence = "The quotient of " + x + " and " + y + " is " + ans + " with a remainder of " + remain + "."; return sentence; } public static void Main() { //test 1 Console.WriteLine(QuotientString(10, 5)); //test 2 Console.WriteLine(QuotientString(2, 4)); //test 3 Console.WriteLine(QuotientString(100, 9)); //user test int a = UIF.PromptInt("Enter an integer: "); int b = UIF.PromptInt("Enter another integer: "); Console.WriteLine(QuotientString(a, b)); } } }
public static void Main(string[] args) { //initilization double ex0; double lab0; double hw0; double pro0; double par0; double left0 = 100; double ex1; double lab1; double hw1; double pro1; double par1; double ex2; double lab2; double hw2; double pro2; double par2; double fin; string fing; bool done = false; while (done == false) { //intro Console.WriteLine("Welcome to The Grade Calculator."); Console.WriteLine("Follow the directions to find out what your grade is."); string name = UIF.PromptLine("What is your name: "); //Console.WriteLine ("What is your name?"); //string name = Console.ReadLine (); Console.WriteLine("Hello, {0}.", name); Console.WriteLine(" "); //asking for exam weights do { ex0 = UIF.PromptInt("What are your exams weighted? (You have " + left0 + "% left): "); //string ex = Console.ReadLine (); //ex0 = double.Parse (ex); left0 -= ex0; lab0 = UIF.PromptInt("What are your labs weighted? (You have " + left0 + "% left): "); //string lab = Console.ReadLine (); //lab0 = double.Parse (lab); left0 -= lab0; hw0 = UIF.PromptInt("What is your homework weighted? (You have " + left0 + "% left): "); //string hw = Console.ReadLine (); //hw0 = double.Parse (hw); left0 -= hw0; pro0 = UIF.PromptInt("What are your projects weighted? (You have " + left0 + "% left): "); //string pro = Console.ReadLine (); //pro0 = double.Parse (pro); left0 -= pro0; par0 = UIF.PromptInt("What is your participation weighted? (You have " + left0 + "% left): "); //string par = Console.ReadLine (); //par0 = double.Parse (par); left0 -= par0; double sum0 = (ex0 + lab0 + hw0 + pro0 + par0); if (sum0 != 100.00) { Console.WriteLine("Your number don't add up 100%, check that out and try again."); left0 = 100; } } while((ex0 + lab0 + hw0 + pro0 + par0) != 100); //asking for user's grades Console.WriteLine(" "); Console.WriteLine("Enter your grade on exams."); double n0 = UIF.PromptDouble("How many total grades do you have: "); ex1 = findAverage(n0); if (ex1 > 1) { Console.WriteLine("Calculated average exam grade = {0:F1}", ex1); } Console.WriteLine(" "); //string e = Console.ReadLine (); //ex1 = double.Parse (e); Console.WriteLine("Enter your grade on labs."); double n1 = UIF.PromptDouble("How many total grades do you have: "); lab1 = findAverage(n1); if (lab1 > 1) { Console.WriteLine("Calculated average labs grade = {0:F1}", lab1); } Console.WriteLine(" "); //string l = Console.ReadLine (); //lab1 = double.Parse (l); Console.WriteLine("Enter your grade on homework."); double n2 = UIF.PromptDouble("How many total grades do you have: "); hw1 = findAverage(n2); if (hw1 > 1) { Console.WriteLine("Calculated average homework grade = {0:F1}", hw1); } Console.WriteLine(" "); //string h = Console.ReadLine (); //hw1 = double.Parse (h); Console.WriteLine("Enter your grade on projects."); double n3 = UIF.PromptDouble("How many total grades do you have: "); pro1 = findAverage(n3); if (pro1 > 1) { Console.WriteLine("Calculated average projects grade = {0:F1}", pro1); } Console.WriteLine(" "); //string pr = Console.ReadLine (); //pro1 = double.Parse (pr); Console.WriteLine("Enter your grade on participation."); double n4 = UIF.PromptDouble("How many total grades do you have: "); par1 = findAverage(n4); if (par1 > 1) { Console.WriteLine("Calculated average participation grade {0:F1}", +par1); } Console.WriteLine(" "); //string pa = Console.ReadLine (); //par1 = double.Parse (pa); //calculations ex2 = (ex0 * ex1) / 1000.00; lab2 = (lab0 * lab1) / 1000.00; hw2 = (hw0 * hw1) / 1000.00; pro2 = (pro0 * pro1) / 1000.00; par2 = (par0 * par1) / 1000.00; double sum2 = ex2 + lab2 + hw2 + pro2 + par2; fin = sum2 * 10.0; if (fin > 93) { fing = "A"; } else if (fin > 90) { fing = "A-"; } else if (fin > 87) { fing = "B+"; } else if (fin > 83) { fing = "B"; } else if (fin > 80) { fing = "B-"; } else if (fin > 77) { fing = "C+"; } else if (fin > 73) { fing = "C"; } else if (fin > 70) { fing = "C-"; } else if (fin > 67) { fing = "D+"; } else if (fin > 63) { fing = "D"; } else if (fin > 60) { fing = "D-"; } else { fing = "F"; } //answer to their question Console.WriteLine("{0}, your final grade is a {1}%.", name, fin); Console.WriteLine("You got an {0} in the class.", fing); Console.WriteLine("Press Y to do another calculation"); string result = Console.ReadLine(); //check to see if user wants to do another calculation if ((result).Equals("y")) { done = false; left0 = 100; } else if ((result).Equals("Y")) { done = false; left0 = 100; } else { done = true; } } Environment.Exit(0); }
static void Main() { int credits = UIF.PromptInt("Please enter your current credits: "); checkCredits(credits); }