ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 06 May 2017 My Price 8.00

This program calculates the measure of one interior

Can you write a line of code so the user can enter a 0 for input. The program works fine until I enter a 0. I can make the program print a message stating that all of the values must be positive, but then the program exits and does not show the results for the other functions.

I provided the instructions for this assignment and code that I have created as an attachment.

To verify if the program was working properly, I entered the following numbers for input

10

1

0

2

-20

N/A

The program can not except a negative integer or a zero as input, but should continue to return the other functions.

Note: This program calculates the measure of one interior or exterior angle ofa regular polygon#include <stdio.h>int main (){/* variable definition: */int intNumber, menuSelect;double Results;intNumber = 1;// While a positive numberwhile (intNumber > 0){printf ("Enter the number of sides of the polygon:\n");scanf("%d", &intNumber);if (intNumber > 0){printf("Enter 1 to Calculate the size of one Interior angle of a regularpolygon \nEnter 2 to Calculate the size of one Exterior angle of a regularpolygon\n");scanf("%d", &menuSelect);if (menuSelect == 1){// Call the size of Interior Angle FunctionResults = Interior(intNumber);printf("Interior Angle of a regular polygon with %d sides = %.1lfËš\n",intNumber, Results);}else if (menuSelect == 2){// Call the size of Exterior Angle FunctionResults = Exterior(intNumber);printf("Exterior Angle of a regular polygon with %d sides = %.1lfËš\n",intNumber, Results);}elseprintf("Invalid menu item, only 1 or 2 is accepted\n");}if (intNumber < 0)printf("Value must be greater than 0");break;}return 0;}/* function returning the interior angle of a number */int Interior(int number){return (double)(number-2)*180/number;}/* function returning the exterior angle of a number */int Exterior(int number){

Attachments:

Answers

(11)
Status NEW Posted 06 May 2017 02:05 AM My Price 8.00

-----------

Not Rated(0)