i have some amature questions . please help me .

1-in this program i need Average of 3 numbers but it dose not work :

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

namespace ConsoleApplication76
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            int y;
            int m;
            float ave;
            Console.ReadLine();
            Console.ReadLine();
            Console.ReadLine();
            ave = x + y + m / 3;
            Console.WriteLine(ave);
            Console.ReadKey(true);


        }
    }
}

2-in this one , program must be ask me Radius of circle and then calculate Environment and Area of circle

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

namespace ConsoleApplication76
{
    class Program
    {
        static void Main(string[] args)
        {
int r;
float area;
float pi;
Console.Writeline("enter radius circle");
environment=Conver.Toint32(Console.ReadLine(r));
area= p * r * r;
pi = 2 * p *r;
Console.Writeline(area,p);

3-this one must be aks me enter 5 numbers and then print them

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

namespace ConsoleApplication77
{
    class Program
    {
        static void Main(string[] args)
        {
            int i;
            const int n = 5;
            Console.ReadLine();
            for (i = 0; i < n; i++) ;
                Console.WriteLine(i);
                Console.ReadKey(true);


        }
    }
}

4-and the last one must be ask me to sentence and then if they are equal must be print equal else it must be print unequal .

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

namespace ConsoleApplication77
{
    class Program
    {
        static void Main(string[] args)
        {
            int i;
            const int n = 5;
            Console.ReadLine();
            for (i = 0; i < n; i++) ;
                Console.WriteLine(i);
                Console.ReadKey(true);


        }
    }
}

i can't complete them , please help me

Recommended Answers

All 10 Replies

Hello, drfarzad.
1. You call the Console.ReadLine(); and don't assign the value, entered by user to any of variables.
2. You miss a letter in the word 'Convert'.
3. You don't 'memorize' any of the pressed keys.
4. Same as in 3.

1.

int x;
int y;
int m;
float ave;
x = Console.ReadLine();
y = Console.ReadLine();
m = Console.ReadLine();
ave = (x + y + m) / 3;
Console.WriteLine(ave);
Console.ReadKey(true);


2.

int r;
float area;
float pi;
Console.Writeline("enter radius circle");
int environment=Convert.Toint32(Console.ReadLine(r));
area = p * r * r;
pi = 2 * p * r;
Console.Writeline(area,p);

Just concentrating on the first problem

int x;
int y;
int m;
float ave;
Console.ReadLine();
Console.ReadLine();
Console.ReadLine();
ave = x + y + m / 3;
Console.WriteLine(ave);
Console.ReadKey(true);

As Antenka and papuccino1(Hi how is your baby boy doing?) are saying: use x = Console.ReadLine(); but then you have a problem, ReadLine returns a string and x is an int. These types are not compatible. So use x = int.Parse(Console.ReadLine());
Same with ave = x + y + m/3. papuccino1 did an improvement by doing ave = (x + y +m) / 3. But still this is an integer division which is implicitly converted to a float. (So it is truncated. You can use ave = (x + y +m) / 3F; here or make x,y,m float also.

first program resolved ...
on second and third and fourth i have still problem yet .
of course i used Antenka guide but it dose not resolve
any body have idea ?

Second : revisit your formulas for the area and circumference of a circle. Notice pi or p variables. I assume you know that pi = 3.14159...
Use that as a const, but better is to use Math.PI.

Is this complete?

if not - on #2 see Class Derivation about halfway down on

http://functionx.com/csharp/Lesson14.htm

partial start of code

using System;

public class Circle
{
    private double _radius;

    public double Radius
    {
	get
	{
	    return _radius;
	}

For #3 - do you have to store them in an array or can you print them out as they are entered? If you can do one at a time then maybe putting your readline inside your loop helps you get further.

For #4 I don't understand what is supposed to be equal to your sentence

I can understand you have troubles(not only with computer language) but also with english. I infer I would have much trouble if I would try to speak your native language...
On point 4 you write :
4-and the last one must be ask me to sentence and then if they are equal ...
Does to sentence mean two sentences?

everyone in this ticket just want to increase their posts and all of them are like spams and abuse , just reply me the perfect solution !

Why would I increase my posts? What benefit would I get out of that? Do you think Daniweb pays me? Do you think I am a moron?
I helped solving your first problem. Are you going to sit on your lazy b*t untill the rest comes in? Do you think you are going to be served for the rest of your life? I could say other things here but the rules don't allow me to do that(luckily)
Bye, get yourself a life...

Well bummer, I was hoping I could edit my previous post and take out my suggestions.

NOBODY will do your work for you. First of all the forum rules prohibit it, secondly it doesn't help you learn didly squat. I'm offended that you even asked much less accused me of trying to run up a number that means nothing to me, to provide some gain that isn't there. But how about this, not only will I not help you further no matter how much effort you put in at this point I'll make my own statement.

You sir are lazy and won't do your own research or work!

commented: carry on with the good cause +4
commented: Well said ;P +2
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.