Ok so this time before I wrote this program I did more reading and practicing and reading examples of code with method statements and class examples. When I finished this program Im still getting a lot of errors...any help?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem10Pg179
{
    class studentID
    {
        static void Main()
        {
            string studentID;
            int examScores,
               examAverage;
            
            DisplayInstructions();
            Console.WriteLine("\nData Entry");
            studentID = GetStudentID();
            examScores = GetExamScores();
            examAverage = examScores / 3;
            Console.WriteLine("\nPress any key to continue");
            Console.ReadKey();
            DisplayResults(studentID, examScores, examAverage);

            Console.ReadKey();

        }
        public static void DisplayInstructions()
        {
            Console.Clear();
            Console.WriteLine("Student ID and Exam Score Average");
            Console.WriteLine("This program will allow you to enter in the student ID" +
                               "and take the average of three exam scores");
            Console.WriteLine(" ");
            Console.ReadKey();

        
        }

        public static int GetStudentID
        {
            String  studentID;
            Console.WriteLine("Please enter your student ID: ");
            studentID = Console.ReadLine();
            id = int.Parse(studentID);
            return id;
 
        }

        public static int GetExamScores()
        {
            int examScores;   
            Console.Write("Please enter your three exam scores");
            examScores = Console.ReadLine();
            scores = int.Parse(examScores);
            return scores;

            
        }
        public static void DisplayResults(string studentID, int examScores,examAverage) 
        {
            int examScores;
            double AverageofExams = (examScores / 3);
            Console.Clear();
            DisplayInstructions();
            Console.WriteLine("\nResults");
            Console.WriteLine("\nStudent ID:\t\t\t {0}\n" +
                              "\nAverage of Three Exams:\t\t\t{1}" ,string studentID, int examScores, examAverage);
            
            Console.WriteLine("\nPress any key to continue"); 
            Console.ReadKey();
            
           
            

        
        }
        
    } // class ends 


} // namespace ends

here are the errors:

Error 17 The type or namespace name 'examAverage' could not be found (are you missing a using directive or an assembly reference?) 60 76 Problem10Pg179
Error 13 The name 'scores' does not exist in the current context 55 13 Problem10Pg179
Error 16 The name 'scores' does not exist in the current context 56 20 Problem10Pg179
Error 9 The name 'GetStudentID' does not exist in the current context 18 25 Problem10Pg179
Error 10 The best overloaded method match for 'Problem10Pg179.studentID.DisplayResults(string, int, examAverage)' has some invalid arguments 23 13 Problem10Pg179
Error 14 The best overloaded method match for 'int.Parse(string)' has some invalid arguments 55 22 Problem10Pg179
Error 19 Only assignment, call, increment, decrement, and new object expressions can be used as a statement 68 76 Problem10Pg179
Error 21 Only assignment, call, increment, decrement, and new object expressions can be used as a statement 68 103 Problem10Pg179
Error 3 Invalid expression term 'string' 68 76 Problem10Pg179
Error 4 Invalid expression term ',' 68 85 Problem10Pg179
Error 7 Invalid expression term ')' 68 114 Problem10Pg179
Error 2 Identifier expected 60 87 Problem10Pg179
Error 12 Cannot implicitly convert type 'string' to 'int' 54 26 Problem10Pg179
Error 11 Argument 3: cannot convert from 'int' to 'examAverage' 23 51 Problem10Pg179
Error 15 Argument 1: cannot convert from 'int' to 'string' 55 32 Problem10Pg179
Error 20 A local variable named 'examScores' is already defined in this scope 68 91 Problem10Pg179
Error 18 A local variable named 'examScores' cannot be declared in this scope because it would give a different meaning to 'examScores', which is already used in a 'parent or current' scope to denote something else 62 17 Problem10Pg179
Error 1 42 13 Problem10Pg179
Error 5 ; expected 68 85 Problem10Pg179
Error 6 ; expected 68 87 Problem10Pg179
Error 8 ; expected 68 114 Problem10Pg179

**notice two numbers next to each other in the errors are line and column indications**

All syntax errors.

Line 18 you attempt to call a method called GetStudentID. But in line 40 you declare a property called GetStudentID (and declare it wrong). I'm assuming you meant to put () on the end of line 40.

Line 23 you attempt to call a method DisplayResults with 3 parameters. But in line 60 you incorrectly declare a method called DisplayResults. The third parameter needs a type, types don't carry over from other parameters.

Line 42 is an error because of the incorrect method declaration in line 40 (first problem above). Once you fix that this error will go away.

Line 45: You don't declare the variable id, do so.

Line 54: Console.ReadLine returns a string but you are assigning it to an int. Rewrite this.

Line 55: It looks like you think examScores is a string, but you declared it an int in line 52. Change it to a string if you want this to work.

Line 55 (again): you don't declare scores, fix that.

Line 62: You already have a parameter named examScores, you can't declare a method variable of the same name.

Line 68: Don't include the types when calling a method, only when declaring one.


Once you fix those you'll see that line 18 now has an issue. Since it's the same as one of the issue above, I'll let you figure that one out.

commented: helped lead to fixing the issue +2

I have a question if I want the user to input three different exam scores how would i implement that in code? I want to just declare the "examScores" variable insted of just typing out examScore1....2...3.

thank you

ok I polished up my code a bit more, I seem to have lot more errors this time though :(

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem8Pg179
{
    class ClubSales
    {
        static void Main()
        {
            string studentID, 
                  examScores; 
            double examAverage; 

            DisplayInstructions(); // instructions for the user
            Console.WriteLine("\nData entry"); // displays "Data Entry"
            studentID = GetID();  
            examScores = GetScores(); 
            examAverage = (examScores) / 3; 
            Console.Write("\nPress any key to  continue"); // displays the instruction
            Console.ReadKey();       // halt the display window
            DisplayResults( studentID, examScores,examAverage); // display results by calling the identifier

            Console.ReadKey();       // halt the display window
        }

        public static void DisplayInstructions()
        {
            Console.Clear();
            Console.WriteLine("StudentID and exam average program");
            Console.Write("This program will allow you to enter student ID and three exam scores" +
                          " and return the examAverage and studentID");
            Console.WriteLine("");
            //Console.WriteLine(" ");
            Console.ReadKey();       // halt the display window
        }

        public static int GetStudentInfo()  // get student ID and three examScores
        {
            string studentID,
                    examScores;
            double examAverage;
            
            Console.WriteLine("Please enter your student ID: ");
            userID = Console.ReadLine();
            ID = int.Parse(ID); 
            return ID; // return the student ID 

            Console.WriteLine("Please enter your three exam scores:", examScores);
            userScore = Console.ReadLine();
            examScores = int.Parse(Scores);
            return Scores;
        }

        public static double  examAverage()   
        {
            
            double examAverage;
            Console.Write("Your average of the three exams: ", examAverage);
            userAvg = Console.ReadLine(); // allowing input to occur
            userAvgScore = double.Parse(userAvg); // parsing the user input and then displaying the "userAvgScore"
            return userAvgScore;  // return the the average score

        }


        public static void DisplayResults(string StudentID , string examScores, double examAverage   
                                         )
        {
            
            double Averages = examScores;
            
            double AverageofExam = (examAverage) / 3;
            Console.Clear(); // clears the screen of previous material
            DisplayInstructions(); // displays the results to the user
            Console.WriteLine("\nYour Report: ");
            Console.WriteLine("\nStudentID:\t\t\t {0}\n" +
                             "\nExamScores:\t\t\t {1:C0}" +
                             "\nExamAverage: :\t\t\t {2:C0}" 
                               , StudentID, examScores
                             , examAverage,);

            Console.WriteLine("\nPress any key to continue");
            Console.ReadKey();
        }
    } // class ends 


} // namespace ends

here are the errors again:

Error 20 The name 'userScore' does not exist in the current context 51 13 NewGranolaSalesProject
Error 16 The name 'userID' does not exist in the current context 46 13 NewGranolaSalesProject
Error 24 The name 'userAvgScore' does not exist in the current context 62 13 NewGranolaSalesProject
Error 26 The name 'userAvgScore' does not exist in the current context 63 20 NewGranolaSalesProject
Error 23 The name 'userAvg' does not exist in the current context 61 13 NewGranolaSalesProject
Error 25 The name 'userAvg' does not exist in the current context 62 41 NewGranolaSalesProject
Error 21 The name 'Scores' does not exist in the current context 52 36 NewGranolaSalesProject
Error 22 The name 'Scores' does not exist in the current context 53 20 NewGranolaSalesProject
Error 17 The name 'ID' does not exist in the current context 47 13 NewGranolaSalesProject
Error 18 The name 'ID' does not exist in the current context 47 28 NewGranolaSalesProject
Error 19 The name 'ID' does not exist in the current context 48 20 NewGranolaSalesProject
Error 14 The name 'GetScores' does not exist in the current context 19 26 NewGranolaSalesProject
Error 13 The name 'GetID' does not exist in the current context 18 25 NewGranolaSalesProject
Error 15 Operator '/' cannot be applied to operands of type 'string' and 'int' 20 27 NewGranolaSalesProject
Error 1 Invalid expression term ',' 83 32 NewGranolaSalesProject
Error 3 Invalid expression term ',' 83 43 NewGranolaSalesProject
Error 7 Invalid expression term ',' 84 30 NewGranolaSalesProject
Error 9 Invalid expression term ',' 84 43 NewGranolaSalesProject
Error 11 Invalid expression term ')' 84 44 NewGranolaSalesProject
Error 4 ; expected 83 43 NewGranolaSalesProject
Error 5 ; expected 83 45 NewGranolaSalesProject
Error 6 ; expected 55 NewGranolaSalesProject
Error 8 ; expected 84 32 NewGranolaSalesProject
Error 10 ; expected 84 43 NewGranolaSalesProject
Error 12 ; expected 84 44 NewGranolaSalesProject
Error 2 ) expected 83 34 NewGranolaSalesProject

Just starting with the first error as most of them are the same error. Where do you declare the variable userScore that you are using in line 51? You cannot use a variable before it is declared.

where have you declared userID,userScore,userAvgScore and Score?

examAverage = (examScores) / 3;

In line 20, you are setting a double value to equal a division by string.

@Momerath @ cheL oohhhhh so if i declare a variable(identifier) in any method I have to list that in the main() ....hmm wow I think this is a eureka moment and possibly the solution to my difficult time ...

thanks to all of you I finally finished the program free of bugs... one last question I have seen the variable "whichOne" used sometimes in the method header as a parameter does that act like a placeholder as well or what ?

Ex.

public static int GetExamScore(string whichOne(
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.