I am currently working on an assignment that I am stuck on. I posted this question already, but the person didn't answer it adequetly, so I am attempting to get the help needed from someone else. Here is what is being asked.
I HAVE TO BE USING SWITCH AND WHILE STATEMENTS, which is where I got stuck. This is what I came up with so far. Can someone give an example on how to complete it. break.
#include #include int main() { char c; int i; printf("Enter a sentence (ended by a '.' or '!' or '?'): "); scanf("%c", &c); while (c !='.' && c !='?' && c !='!') switch(c) { case 'a': break; case 'e': break; case 'i': break; case 'o': break; case 'u': break; } return 0; }
Lab 4: Selection Statements Lab Goals The goals of this lab are to Get students familiar with while loops 2. Get students familiar with switch statements Important Notes: 1. Formatting: Make sure that you follow the precise recommendations for the output content and formatting: for example, do not change the text in the first problem from "Enter a sentence (ended by a '.' or 'or?"): " to "Enter a sentence: ". Your assignment will be auto-graded and any changes in formatting will result in a loss in the grade Comments: Header comments are required on all files and recommended for the rest of the program. Points will be deducted if no header comments are included. 2. Problem 1 Save your program as sentence.c Write a program that rcads in a scntence, character by character, and counts the total number of charactcrs thc number of vowels, newline characters, tabs, spaces and all other characters. The sentence the user enters will end with either a period, question mark, or exclamation mark. The program will not count the period, exclamation mark, or question mark as a character The program should function as follows (items underlined are to be entered by the user) Enter a sentence (ended by a ''' or '!' or '?'): This* S A sampLE sentence! Total nunber of characters: 28 Number of vowels: 8 Number of newlines: 3 Number of tabs: 1 Number of spaces: 2 Number of other characters: 14 Program Design: 1. Variables a. How many variables do you need? i. ii. One variable for reading in a character from what the user enters A variable for each count you will need to keep track of b. What type should each variable be? 2. Get input from the user a. Print out the prompt b. Read in the first character from the user using scanf