Question

In: Computer Science

Please code in C# - (C - Sharp) Assignment Description Write out a program that will...

Please code in C# - (C - Sharp)

Assignment Description

Write out a program that will ask the user for their name; the length and width of a rectangle; and the length of a square. The program will then output the input name; the area and perimeter of a rectangle with the dimensions they input; and the area and perimeter of a square with the length they input.

Tasks

  1. The program needs to contain the following
    1. A comment header containing your name and a brief description of the program
    2. Output prompting the user for the following inputs:
      1. Name as a string
      2. Length of a rectangle as a double
      3. Width of a rectangle as a double
      4. Length of a square as an int
    3. After accepting user input, the program outputs the following:
      1. User name
      2. Area of a rectangle with dimensions matching the inputs
        • Area of a rectangle = Length * Width
      3. Perimeter of a rectangle with dimensions matching the inputs
        • Perimeter of a rectangle = (2 * length) + (2 * Width)
      4. Area of a square with dimensions matching the inputs
        • Area of a square = Length * Length
      5. Perimeter of a square with dimensions matching the inputs
        • Area of a square = 4 * length
    4. “Press enter to continue”
    5. Console.Read(); at the end of your code

Solutions

Expert Solution

Code Screenshots:

Sample Output:

Code To Copy:

//Use the

//required modules.

using System;

//Define

//the MainClass.

class MainClass

{

    //Define the

    //Main() method.

    public static void Main(string[] args)

    {

        //Declare the

        //required variables.

        string name;

        double rect_length;

        double rect_width;

        int square_length;

        double area_rect;

        int area_square;

        double perimeter_rect;

        int perimeter_square;

        //Prompt the user

        //to enter the name.

        Console.Write("Enter the name: ");

        //Read and store the name.

        name = Console.ReadLine();

        //Prompt the user to enter

        //the length of the rectangle.

        Console.Write("Enter the length of the rectangle: ");

        //Read and store the

        //length of the rectangle.

        rect_length = Double.Parse(Console.ReadLine());

        //Prompt the user to enter

        //the width of the rectangle.

        Console.Write("Enter the width of the rectangle: ");

        //Read and store the

        //width of the rectangle.

        rect_width = Double.Parse(Console.ReadLine());

        //Prompt the user to enter

        //the length of the square.

        Console.Write("Enter the length of the square: ");

        //Read and store the

        //length of the square.

        square_length = Convert.ToInt32(Console.ReadLine());

        //Calculate the area

        //of the rectangle.

        area_rect = rect_length * rect_width;

        //Calculate the

        //perimeter of the rectangle.

        perimeter_rect = (2 * rect_length) + (2 * rect_width);

        //Calculate the

        //area of the square.

        area_square = square_length * square_length;

        //Calculate the

        //perimeter of the square.

        perimeter_square = 4 * square_length;

        //Display the name.

        Console.WriteLine("Name: {0}", name);

       

        //Display the required results.

        Console.WriteLine("Area of rectangle: {0}", area_rect);

        Console.WriteLine("Perimeter of rectangle: {0}", perimeter_rect);

        Console.WriteLine("Area of square: {0}", area_square);

        Console.WriteLine("Perimeter of square: {0}", perimeter_square);

        Console.WriteLine("Press enter to continue");

        Console.Read();

    }

}


Related Solutions

Please code in C# (C-Sharp) Assignment Description A pirate needs to do some accounting and has...
Please code in C# (C-Sharp) Assignment Description A pirate needs to do some accounting and has asked for your help. Write a program that will accept a pirate’s starting amount of treasure in number of gold pieces. The program will then run one of two simulations, indicated by the user: 1) The first simulation runs indefinitely, until one of two conditions is met: the pirate’s treasure falls to 0 or below, or the pirate’s treasure grows to 1000 or above....
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
Assignment Description: Write a C++ program for keeping a course list for each student in a...
Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object that contains the student id (four digit integer), name (string), and a list of courses completed by the student. The course taken by a student are stored as a linked list in which each node contain course name (string such as CS41, MATH10), course unit (1 to 4) and the course grade (A,B,C,D,F)....
*Please write code in C++* Write a program to verify the validity of the user entered...
*Please write code in C++* Write a program to verify the validity of the user entered email address.   if email is valid : output the stating that given email is valid. ex: "The email [email protected] is valid" else : output the statement that the email is invalid and list all the violations ex:  "The email sarahwinchester.com is invalid" * @ symbol * Missing Domain name The program should keep validating emails until user enter 'q' Upload your source code. ex: main.cpp
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into BMI is as follows: BMI = Weight *...
C++ Please For this assignment, you will write a program that lets the user play against...
C++ Please For this assignment, you will write a program that lets the user play against the computer in a variation of the popular blackjack car game. In this variation of the game, two-six sided dice are used instead of cards. The dice are rolled, and the player tries to beat the computer's hidden total without going over 21. Here are some suggestions for the game's design: Each round of the game is performed as an iteration of a loop...
Code in C++ please You are going to write a program for Computer test which will...
Code in C++ please You are going to write a program for Computer test which will read 10 multiple choice questions from a file, order them randomly and provide the test to the user. When the user done the program must give the user his final score
CODE MUST BE IN C++ (please use for loop) write a program that loops a number...
CODE MUST BE IN C++ (please use for loop) write a program that loops a number from 1 to 10 thousand and keeps updating a count variable (count variable starts at 0 ) according to these rules: n1 = 14 n2 = 54 n3 = 123 if the number is divisible by n1, increase count by 1 if the number is divisible by n2, increase count by 2 if the number is divisible by n3, increase count by 3 if...
Please code C# 8. Write a program that prompts the user to enter an integer. The...
Please code C# 8. Write a program that prompts the user to enter an integer. The program then determines and displays the following: Whether the integer is divisible by 5 and 6 Whether the integer is divisible by 5 or 6
PLEASE WRITE IN C++ PROGRAM THANKS - QUEUES Please study the code posted below. Please rewrite...
PLEASE WRITE IN C++ PROGRAM THANKS - QUEUES Please study the code posted below. Please rewrite the code implementing a template class using a linked list instead of an array. Note: The functionality should remain the same /** * Queue implementation using linked list C style implementation ( no OOP). */ #include <cstdio> #include <cstdlib> #include <climits> #include <iostream> #define CAPACITY 100 // Queue max capacity using namespace std; /** Queue structure definition */ struct QueueType { int data; struct...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT