Please help

Pages: 12
Nov 8, 2012 at 2:51pm
I have two questions and i do not know how to solve them.
Can someone help me please?





1. Create a class named Circle. The members of the class are radius, area, and diameter. Include the following methods
1. set () which reads the value for radius from the user.
2. computediameter() to find the diameter of the circle( 2* radius)
3. computearea() to find the area of the Circle(3.14 * r* r)
4. printall () prints diameter, radius, area.
5. Create two objects for the class and print.




2. Write a class called Account which contains two private data elements, an integer accountNumber and a double accountBalance, and three member functions:
1. A constructor that allows the user to set initial values for accountNumber and accountBalance.
2. A function called inputTransaction, which reads a character value for transactionType ('D' for deposit and 'W' for withdrawal), and a double value for transactionAmount, which updates accountBalance.
3. A function called printBalance, which prints on the screen the accountNumber and accountBalance.
4. Test your functions in the main method.



Last edited on Nov 8, 2012 at 2:54pm
Nov 8, 2012 at 3:00pm
Do you know how to create a class?
Nov 8, 2012 at 3:08pm
Like this?



class classname
{
private :
members;
list of functions;
public :
members;
list of functions;
protected:
members;
list of functions;
}
Nov 8, 2012 at 3:14pm
Make one called Circle.
Nov 8, 2012 at 3:17pm
I know only general small ideas but the exact details i do not know how.

Can you donate and solve it for me please?
Nov 8, 2012 at 3:18pm
1
2
3
class Circle{

};


Now you fill in the rest from the instructions;
The members of the class are radius, area, and diameter. Include the following methods...

Nov 8, 2012 at 3:25pm
Like this??

class Circle
{
float radius, area,diameter;
viod set()
void computediameter()
void computearea()
void printall()
};
Nov 8, 2012 at 3:30pm
Please use the markup for code.

You need to put
[/code]
after your code, and
[code]
before your code.

You can do this easily by highlighting all your code and clicking the <> in the box on the right.

Your class has void spelled wrong and is missing a lot of semi-colons.
Last edited on Nov 8, 2012 at 3:31pm
Nov 8, 2012 at 3:37pm
Like this??

1
2
3
4
5
6
7
8
class Circle
{
float radius, area,diameter;
viod set()
void computediameter()
void computearea()
void printall()
};

Nov 8, 2012 at 3:49pm
Like this?

1
2
3
4
5
6
7
8
class Circle
{
float radius, area,diameter;
void set();
void computediameter();
void computearea();
void printall();
};
Nov 8, 2012 at 3:49pm
Thin what to do?
Nov 8, 2012 at 3:52pm
Thin what to do?


Write the functions.
Nov 8, 2012 at 4:04pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Circle
{
float radius,area,diameter;
void set()
{
cout<<"Please enter the value of radius"<<endl
cin>>radius<<
};
void computediameter()
{
cout<<""diameter is: "<<diameter<<endl;
diameter=2*radius;
};
void computearea()
{
cout<<"Area is: "<<area<<endl;
area=3.14 * radius* radius;
};
void printall()
{
cout<<radius<<endl;
cout<<area<<endl;
cout<<diameter<<endl;
}; 
Nov 8, 2012 at 4:05pm
Correct?
Nov 8, 2012 at 4:11pm
You quite clearly know how to do this. Why did you turn up and say you did not know how to do this?
Nov 8, 2012 at 4:13pm
i know but i get errors when i compile it
Nov 8, 2012 at 4:15pm
And i need to call the methods from the main
Nov 8, 2012 at 4:17pm
i know but i get errors when i compile it


I will use my psychic powers to guess what the errors are, shall I?

http://www.cplusplus.com/articles/Ny86b7Xj/
Nov 8, 2012 at 4:18pm
Also i need to Create two objects for the class and print

How to do that?
Nov 8, 2012 at 4:25pm
If you do not know how to create an object, give up now. This is far too advanced for you. Most people have learned in the first five minutes how to do this. Here is what they learn first; creating an object of type int.

int x;
Pages: 12