Mary Cooper
Mary Cooper
CC#
Created by Mary Cooper on 4/12/2024 in #help
beginner help
No description
34 replies
CC#
Created by Mary Cooper on 3/11/2024 in #help
✅ Beginner loop
I need to make it so if the user doesnt enter an integer it gives an error. ive done this but if they enter 'cat' the error only shows up for a a split second and then the program closes. do { try { Console.WriteLine(); Console.Write("Input test score: "); testscore = Convert.ToInt32(Console.ReadLine()); } catch { Console.WriteLine("Invalid Integer... Press Enter To Exit."); Console.ReadLine(); return; }

if (testscore == -1) { Console.Write("Well done, Pres ENTER To Exit...."); Console.ReadLine(); Console.WriteLine(); Environment.Exit(0); } else if (testscore < -1) { Console.WriteLine("Invalid Integer. Please Retry"); } else if (testscore > 100) { Console.WriteLine("Invalid. Please Enter Your Test Score."); }
else if (testscore >= 0 && testscore <= 49) { Console.WriteLine("You need to put in more work!");
} else if (testscore >= 50 && testscore <= 79) { Console.WriteLine("Could you do better? ");
} else if (testscore >= 80 && testscore <= 100) { Console.WriteLine("Well Done!");
}
} while (true);
} } }
71 replies
CC#
Created by Mary Cooper on 3/10/2024 in #help
✅ Beginner help
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exercise_2_Task_1 { internal class Program { static void Main(string[] args) { int testscore = 0; do { Console.WriteLine(); Console.Write("Input test score: "); testscore = Convert.ToInt32(Console.ReadLine());
if (testscore == -1) { Console.Write("Well done, Pres ENTER To Exit...."); Console.ReadLine(); Console.WriteLine(); Environment.Exit(0); } else if (testscore < -1) { Console.WriteLine("Invalid Integer. Please Retry"); } else if (testscore > 100) { Console.WriteLine("Invalid Integer. Please Retry"); }
else if (testscore >= 0 && testscore <= 49) { Console.WriteLine("You need to put in more work!");
} else if (testscore >= 50 && testscore <= 79) { Console.WriteLine("Could you do better? ");
} else if (testscore >= 80 && testscore <= 100) { Console.WriteLine("Well Done!");
}
} while (true);
} } } How can i make it so if they enter like a word 'dog' it says invalid. And Re loops again
30 replies
CC#
Created by Mary Cooper on 2/29/2024 in #help
✅ c# beginner help
Im wanting all of the times tables to list as soon as i click type the number and click enter but its making me click enter to display each time table. Thanks Console.WriteLine("Enter number to see times table!"); int multiple = Convert.ToInt32(Console.ReadLine()); for (int number = 0; number < 13; number++) { Console.ReadLine();
int result = multiple * number; Console.WriteLine($"{number} * {multiple} = {result}"); }
12 replies