worldtraveller123
New member
- Joined
- Nov 16, 2022
- Messages
- 2
- Programming Experience
- Beginner
im struggling to save the user inputted data into a text file. i know that im supposed to be using stream writer and stream reader but i cannot implement it. if anyone can help itd be great, thanks.
C#:
Console.WriteLine("Enter the marks for module 5: ");
module5 = Convert.ToInt32(Console.ReadLine());
while (module5 < 0 || module5 > 100)
{
Console.WriteLine("Enter the marks for module 5: This should be between 0-100%: ");
module5 = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Enter the marks for module 6: ");
module6 = Convert.ToInt32(Console.ReadLine());
while (module6 < 0 || module6 > 100)
{
Console.WriteLine("Enter the marks for module 6: This should be between 0-100%: ");
module6 = Convert.ToInt32(Console.ReadLine());
}
average = (module1 + module2 + module3 + module4 + module5 + module6) / 6;
if (average < 40)
{
Console.WriteLine("The average mark you got was: " + average+"%");
Console.WriteLine("You have failed");
}
else
{
Console.WriteLine("The average mark you got was: " + average + "%");
Console.WriteLine("You have passed");
}
Console.ReadKey();