0

Please note that I am not asking for an answer to the exercise just abit more explanation

I have this question that I do not understand.

Using a class to wrap simple stream input (InputWrapper.cs) modify following program to
calculate area of a triangle given base and height

using System; 
class Triangle 
{ 
 static void Main() 
 { 
 //Sample code to calculate area of triangle 
double Base = 15; 
 double height = 5; 
 double area = Base * height / 2; 
 Console.WriteLine("Area = {0}", area); 
 Console.Read(); 

 } 
} 



// InputWrapper.cs 
// Class to wrap simple stream input 
// Datatype supported: 
// int 
// double 
// decimal 
// string 
using System; 
class InputWrapper 
{ 
 public int getInt(string prompt) 
 { 
 Console.Write(prompt); 
 string buf = Console.ReadLine(); 
 return Convert.ToInt32(buf); 
 } 
 public double getDouble(string prompt) 
 { 
 Console.Write(prompt); 
 string buf = Console.ReadLine(); 
 return Convert.ToDouble(buf); 
 } 
 public decimal getDecimal(string prompt) 
 { 
 Console.Write(prompt); 
 string buf = Console.ReadLine(); 
 return Convert.ToDecimal(buf); 
 } 
 public string getString(string prompt) 
 { 
 Console.Write(prompt); 
 string buf = Console.ReadLine(); 
 return buf; 
 } 

Could someone who may understand what is asked please give me abit of a clearer explanation?

Thankyou

2
Contributors
2
Replies
22
Views
3 Years
Discussion Span
Last Post by iConqueror
1

Instead of using double Base = 15; on line 7 in your Main,
use a method from the InputWrapper class.
Example: change line 7 with
double Base InputWrapper.getDouble("What is base of triangle?");
Do the same sort of thing on line 8.
Success!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.