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.
C Program: Create a C program that prints a menu and takes user choices as input....
C Program: Create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. The specifications must be followed exactly, or else the input given in the script file may not match with the expected output. Important! Consider which control structures will work best for which aspect of the assignment. For example, which would be the best to use for a menu?...
C Program: Create a C program that prints a menu and takes user choices as input....
C Program: Create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. The specifications must be followed exactly, or else the input given in the script file may not match with the expected output. Your code must contain at least one of all of the following control types: nested for() loops a while() or a do-while() loop a switch() statement...
(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 which will accept an unlimited number of scores and calculates the average...
Create a C++ program which will accept an unlimited number of scores and calculates the average score. You will also need to prompt for the total points possible. Assume each test is worth 100 points. Requirements. • Enter the Student ID first, then prompt for grades. Keep prompt- ing for grades until the client enters ’calc’. That triggers final pro- cessing. • Make your code as reliable as possible. • Make your program output easy to read. • You cannot...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT