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
Mohammed Musekula
NA
36
10.9k
CalculateArea(int option) using interface in C#
Mar 15 2015 11:41 AM
How do I solve this conundrum?
I am new to C#, and I am completely lost. This is my homework but I can't figure out how to deal with the missing script/ parts of the following interface:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calculate_Area {
class Program {
/// <summary>
///
/// </summary>
/// <param name="option"></param>
static void CalculateArea(int option) {
if (option == 1) {
CircleArea();
} else if (option == 2) {
RectangleArea();
} else {
CylinderArea();
}//end if else
}//end CalculateArea
/// <summary>
/// Inputs user choice
/// </summary>
/// <returns> 1,2, 3 or 0</returns>
static int ReadMenuOption() {
int option = 0;
bool validMenuOption = false;
do {
option = int.Parse(Console.ReadLine());
if ((option >= 0) && (option <= 3)) {
validMenuOption = true;
} else {
Console.WriteLine("\n\t Option must be 1, 2, 3 or 0");
DisplayMenu();
} //end if
} while (!validMenuOption);
return option;
} //end ReadMenuOption
/// <summary>
/// Display shape menu
/// </summary>
static void DisplayMenu() {
string menu = "\n 1) Circle"
+ "\n 2) Rectangle"
+ "\n 3) Cylinder (closed)"
+ "\n\nEnter your choice(1, 2, 3 or 0 to exit):";
Console.Write(menu);
} //end DisplayMenu
static void Main() {
int menuOption;
DisplayMenu();
menuOption = ReadMenuOption();
if (menuOption != 0) {
CalculateArea(menuOption);
}// end if
Console.ReadKey();
}
}
}
Reply
Answers (
2
)
shortdate
.NET