2
Reply

Passing parametre to console.writeLine

Henry Lhteenmaki

Henry Lhteenmaki

Nov 26 2011 11:42 AM
1.2k
Hi !


The program seems to be ok , the only issue witch I do not understand when I tried to display the message content .

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

namespace Assignment3
{
    class Program
    {
        static void Main(string[] args)
        {
          
            // Declare variables
            int score1, score2, score3;
            decimal avr;
            string name, message = "";

            //Users names

            Console.WriteLine("Enter you name");
            name = Console.ReadLine();
           
            //users score

            Console.WriteLine("Enter your first score");
            score1 = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter your Second score");
            score2 = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter your Third score");
            score3 = int.Parse(Console.ReadLine());


            // calculate Average
           
            avr = ( (score1 + score2 + score3)/3 );

            // Testing the average

            if (avr >= 90 && avr <= 100)
            {
           
                message = "Wow, you did great";
            }

            else if (avr >= 80 && avr <= 89)
            {
           
                 message = "Pretty good!";
            }

            else if (avr >= 75 && avr <= 79)
            {
           
                message = "That was close....";
           
            }

            else if (avr < 75)
            {

                message = "Better luck next time";
           
            }


            /* In this step do not understad
              why the message cannot display */
           
            Console.WriteLine("Hi {0}, {1}", name, message);
            Console.ReadLine();
            return;
            }
        }
    }


Thanks in advance

Answers (2)