I have a c# code below. This code takes the name, marks for maths, computer, science, environment and History from the user and prints the total and percentage. The problem with this code is that it takes only the marks from maths. And it prints the output. But it takes the number from maths and assigns that number to all other subjects. Please help me out with this problem. The code goes like this:
using System;
namespace test
{
class Program
{
public static void Main(string[] args)
{
int total = 500;
Console.WriteLine("Hello This is my first C# Program. Hope you like it");
Console.Write("Enter a name: ");
String name = Console.ReadLine();
Console.WriteLine($"Hello {name}");
Console.Write("Enter the marks for Maths: ");
int mathsMarks = Console.Read();
Console.Write("Enter the marks for Science: ");
int scienceMarks = Console.Read();
Console.Write("Enter the marks for Computer: ");
int computerMarks = Console.Read();
Console.Write("Enter the marks for Environment: ");
int environmentMarks = Console.Read();
Console.Write("Enter the marks for Social: ");
int socialMarks = Console.Read();
int totalMarks = mathsMarks + scienceMarks + computerMarks + environmentMarks + socialMarks;
Console.WriteLine($"The total marks is {totalMarks}");
Console.WriteLine($"The percentage is %{(totalMarks/total)*100}");
}
}
}