TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kel Michael
NA
9
29.9k
working on project with four classes (need serious help)
Nov 2 2010 4:18 PM
create an application with four classes. three of the classes should contain data and behavior characteristics for circle, rectangle, and cylinder. the fourth class should allow the user to input a figure type from a menu of options. prompt for appropiate values based on the inputted figure type, instantiate an object of the type entered, and display characteristics about the object.
i have code for the circle but i cant figure out how to make the main class work with the other classes (circle, rectangle, and cylinder)
here is my code for the circle:
using System;
public class Sphere
{
// obtain radius from user and display volume of sphere
public void DetermineSphereVolume()
{
Console.Write( "Enter radius of sphere: " );
double radius = Convert.ToDouble( Console.ReadLine() );
Console.WriteLine( "Volume is {0:F3}", SphereVolume( radius ) );
} // end method DetermineSphereVolume
// calculate and return sphere volume
public double SphereVolume( double radius )
{
double volume = ( 4.0 / 3.0 ) * Math.PI * Math.Pow( radius, 3 );
return volume;
} // end method SphereVolume
} // end class Sphere
// Calculate the volume of a sphere.
public class SphereTest
{
// application starting point
public static void Main( string[] args )
{
Sphere mySphere = new Sphere();
mySphere.DetermineSphereVolume();
} // end Main
} // end class SphereTest
Reply
Answers (
3
)
C# class or no class... question from newbie
Web Application which requires keyboard input even without browser focus