English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Create the equivalents of a four-function calculator. The program should request the user to enter a number, an operator, and another number. (Use floating point). It should then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two numbers. Use switch case statement to select the operation. Finally display the result.
When it finishes the calculation, the program should ask if the user wants to do another calculation. The response can be ‘y’ or ‘n’.
Sample Output
Some sample interaction with the program might look like this:

Enter first number, operator, second number: 10/3
Answer: 3.33333
Do another (y/n)?y
Enter first number, operator, second number: 12+100
Answer: 112
Do another (y/n)?n

2006-10-27 03:54:15 · 3 answers · asked by Muhammad A 1 in Computers & Internet Programming & Design

3 answers

You aren't seriously suggesting we do your homework are you? I will but it will cost you $100 US and you will fail the exam 'cause you didn't learn anything.

If you want info on the 'switch statement' see below.

2006-10-27 04:00:22 · answer #1 · answered by jan 7 · 5 0

You need to use a loop statement to not display errors. And there may be errors/warning even in C#, but they are just not being displayed (it is a parameter to the compiler). Try this instead: /* program to determine if input character is a vowel */ #include void main() {  char ans;  bool done = false;  /* Loop until done */  while (done == false)  {    printf("enter a character in lower case: ");    scanf("%c",&ans);    switch(ans)    {    case 'a':      printf(" character is 'a' which is vowel");      done = true;  /* set flag that it's time to exit the loop */      break;    case 'e':      printf(" character is 'e' which is vowel");      done = true;  /* set flag that it's time to exit the loop */      break;    case 'i':      printf(" character is 'i' which is vowel");      done = true;  /* set flag that it's time to exit the loop */      break;    case 'o':      printf(" character is 'o' which is vowel");      done = true;  /* set flag that it's time to exit the loop */      break;    case 'u':      printf(" character is 'u' which is vowel");      done = true;  /* set flag that it's time to exit the loop */      break;    default:      printf(" entered character is not a vowel");      break;    }  } }

2016-05-22 00:43:00 · answer #2 · answered by ? 4 · 0 0

Programmers usually expect to be paid for their services, especially when I (or we) do all the work.

2006-10-27 04:08:48 · answer #3 · answered by D 4 · 2 0

fedest.com, questions and answers