Jump to content

need help in sqareApp program ?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
maximus123

maximus123

    Newbie

  • Members
  • PipPip
  • 13 posts
// objective create a program in c# console APP make the program calculate the sum, difference, product, and finally average it .

my problem is for some reason im keep getting error in visual studio 2010 while making this program

may be some one can help me out?

here are my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SquaredResult
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputValue;
            int value, //result, square, average, sum, difference, product, addition, intOne, intTwo;
            //DisplayInstruction;
            //SquaredInputValue;
            intOne = GetInt();
            intTwo = GetInt();
            //square = SquaredInputValue;
            sum = ForSum(intOne, intTwo);
            difference = ForDifference(intOne, intTwo);
            product = ForProduct(intOne, intTwo);
            average = ForAverage(intOne, intTwo);
            SquaredInputValue(intOne, intTwo);
            DisplayResult();
        }
        public static int ForSum(int One, int Two)
        {
            return (One + Two);
        }
        public static int ForDifference(int One, int Two)
        {
            return (One - Two);
        }
        public static int ForProduct(int One, int Two)
        {
            return (One * Two);
        }
        public static int ForAverage(int One, int Two)
        {
            return ((One + Two) / 2);
        }
        public static int GetInt()
        {
            string inputValue;
            int value;
            Console.Write("Enter interger : ");
            inputValue = Console.ReadLine();
            value = int.Parse(inputValue);
            return value;
        }
        public static void SquaredInputValue(int One, int Two)
        {
            string inputValue;
            double value;
            double result;
            inputValue = Console.ReadLine();
            value = int.Parse(inputValue);
            inputValue = Console.ReadLine();
            result = Math.Pow(value, 2);
        }
        public static void DisplayInstruction(int One, int Two)
        {
            string inputValue;
            int value;
            Console.Write("Enter two intergers: ");
            inputValue = Console.ReadLine();
            value = int.Parse(inputValue);
            inputValue = Console.ReadLine();
        }
        public static int DisplayResult()
        {
            Console.WriteLine("the Sum is: ");
            Console.WriteLine("\nthe product is: ");
            Console.WriteLine("\nThe average is : ");
            Console.WriteLine("\nThe Squared is : ");
            Console.Read();
            return (DisplayResult());
        }
    }
}

Edited by Alexander, 19 October 2010 - 12:53 AM.
Please add [code] tags around your code


#2
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts
When you have a problem with your code, it would help if you actually told us what the problem was and where it was happening. That said, why do you have all the extra Console.ReadLines() in each method? Isn't that why you asked for two numbers originally? You'll have to change your DisplayResults() method to accept parameters (which are the results), and to display them.

#3
maximus123

maximus123

    Newbie

  • Members
  • PipPip
  • 13 posts
hello momerath thank you for replying to my problem. can you some point out what Console.Realines() method i need and i don't need because im still a beginner programmer so im still sort of confuse on how all of this of program works. you also said that i needed to change my display result ? how can i change them in a way that would make my program works?

again my objective is im trying to make my program calculate the sum, difference, product, and finally average it .

reply back soon




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users