Question

In: Computer Science

Create a working C# Program that will accept an input and has the following class. areaCircle...

Create a working C# Program that will accept an input and has the following class.

areaCircle – computes the area of the circle

volumeCube – computes the volume of a cube

perimeterTraingle – computes the perimeter of a triangle

surfaceAreaRect – computes the surface area of a rectangle

*You may usePass by Value and/or Pass by Reference

*Using ConsoleApp

Solutions

Expert Solution

Program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShapeApp
{
class Program
{
public static double areaCircle(double radius)
{
return (Math.PI * radius * radius);
}

public static double volumeCube(double a)
{
return a * a * a ;
}

public static double perimeterTriangle(double a, double b, double c)
{
return (a + b + c);
}

public static double surefaceAreaRect(double length, double breadth)
{
return (length * breadth);
}
static void Main(string[] args)
{
//using Math.Round() - to get two decimal places
//area of circle
Console.Write("Enter a radius: ");
double radius = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The area of a Circle: "+Math.Round(areaCircle(radius),2));

//volume of a cube
Console.Write("\nEnter a length of the edge of a cube: ");
double a= Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The volume of Cube: "+Math.Round(volumeCube(a),2));

//perimeter of a triangle
Console.Write("\nEnter value of Side1: ");
double side1= Convert.ToDouble(Console.ReadLine());
Console.Write("Enter value of Side2: ");
double side2 = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter value of Side3: ");
double side3 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The perimeter of a Triangle: "+Math.Round(perimeterTriangle(side1,side2,side3)),2);

//surface area of a rectangle
Console.Write("\nEnter the length of a rectangle: ");
double l = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the breadth of a rectangle: ");
double w = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The surface area of a rectangle: "+Math.Round(surefaceAreaRect(l,w)),2);
Console.ReadKey();
}
}
}

Output:


Related Solutions

Create a C++ program that will accept any number of grades for an exam. The grades...
Create a C++ program that will accept any number of grades for an exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1 for a D, and 0 for an F. After all grades have been entered, allow the user to enter -1 to exit. Output the number of grades in each category. Using arrays.
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Create a c++ program with this requirements: Create an input file using notepad ( .txt )...
Create a c++ program with this requirements: Create an input file using notepad ( .txt ) . When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File”...
DO IN C++ Secret Codes! Create a program that will accept a message from the user...
DO IN C++ Secret Codes! Create a program that will accept a message from the user and either encrypt ordecrypt it with the following algorithms: To encrypt: - get the character you wish to encrypt - find the index of that character in the alphabet array - add the shift offset to the index - add the increment to the index - "wrap around" the new index so the result is between 0 and 29 - find the character at...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File” marker. Input date...
C++ * Program 2:      Create a date class and Person Class.   Compose the date class...
C++ * Program 2:      Create a date class and Person Class.   Compose the date class in the person class.    First, Create a date class.    Which has integer month, day and year    Each with getters and setters. Be sure that you validate the getter function inputs:     2 digit months - validate 1-12 for month     2 digit day - 1-3? max for day - be sure the min-max number of days is validate for specific month...
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
C++ Programming Create a C++ program program that exhibits polymorphism. This file will have three class...
C++ Programming Create a C++ program program that exhibits polymorphism. This file will have three class definitions, one base class and three derived classes. The derived classes will have an inheritance relationship (the “is a” relationship) with the base class. You will use base and derived classes. The base class will have at least one constructor, functions as necessary, and at least one data field. At least one function will be made virtual. Class members will be declared public and...
write in c++ Create a program that uses EXCEPTION HANDLING to deal with an invalid input...
write in c++ Create a program that uses EXCEPTION HANDLING to deal with an invalid input entry by a user. a. Write a program that prompts a user to enter a length in feet and inches. The length values must be positive integers. b. Calculate and output the equivalent measurement in centimeters 1 inch = 2.54 centimeters c. Write the code to handle the following exceptions: If the user enters a negative number, throw and catch an error that gives...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT