I am working on a school project but am completely stuck and I don't know where to go from here.
Description:
Professor Jenkins needs a program that will help him calculate the area of a shape. He would like an option to choose a shape and then be prompted for the necessary information to compute the area of that shape. He also wants to be able to calculate the area for as may shapes as he wants. The shapes Professor Jenkins requires the program to handle are: circles, rectangles, triangles.
Requirements:
1. 4 user defined functions (main() and one to handle different shape)
2. sentinel controlled loop to allow Professor Jenkins to enter as many shapes as he wants.
This is what I have so far but am at a total loss if this is even right or where to go from here:
Code:
//----------------------------------------------------------------------------//
// Name: //
// Student ID: //
// Assignment:1 //
//----------------------------------------------------------------------------//
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
// Function prototypes.
int displayMenu(int answer);
float circle(int Radius);
float rectangle(int length, int width);
float triangle(int base, int height);
int main(void)
{//I have no idea to put in here
unsigned int counter = 0;
int option = 0;
while (option != 4){
}
// Display the menu to choose a shape or quit.
int displayMenu(int answer)
{
//declarations
int choice;
//assign the variables values
puts("Choose the shape whose area you would like to compute:");
printf("%s", "1- Circle, 2- Rectangle, 3- Triangle, 4- Quit the program: ");
scanf("%d", &choice);
printf("You chose %d\n", choice);
return choice;
}
float circle(int radius)
{// I don't know if the float and int are correct for any of these
int radius;
float circleArea;
printf("%s", "Enter radius:");
scanf("%d", &radius);
circleArea = (float) 3.14*radius*radius;
printf("The area of the cirlce with radius %d is %.1f\n", radius, circleArea);
puts("");
}
float rectangle(int length, int width)
{
int length;
int width;
float rectangleArea;
printf("%s%s", "Enter length and width of rectangle.");
scanf("%d%d", &length, &width);
rectangleArea = (float)length*width;
printf("The area of the rectangle with length %d and width %d is %.1f\n", length, width, rectangleArea);
puts("");
}
float triangle(int base, int height)
{
int base;
int height;
float triangleArea;
printf("%s%s", "Enter base and height of the triangle.");
scanf("%d%d", &base, &height);
triangleArea = (float) 0.5*(base*height);
printf("The are of the triangle with base %d and height %d is %.1f\n", base, height, triangleArea);
puts("");
}
/*
Copy the results of your program here.
*/