Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Programming Assignment

INTRODUCTION

You'll be creating a menu-driven main program for processing strings, but you'll do this by first writing a set of functions, and then using those functions inside a main program.

Specific deliverables and deadlines will be given for each piece of this assignment. You must complete and submit each piece by the given deadline. Missing any deadline will disqualify you from further consideration on this assignment (in other words, your entire assignment will be graded based only on what you've submitted up to that point).

Submissions will be in the form of a PDF file, showing:

• your well-commented source code;
• its behavior on the given test cases; and
• its behavior on two additional test cases of your own choosing.

Specific commenting guidelines will be given below, and proper commenting will form an essential part of your grades.

PROGRAM OVERVIEW

Here is an overview of the program you'll be writing. The next section will discuss how you should develop your program.

Functions

Write the following functions. Each of these functions should have a single parameter -- accepting a c-style string as an argument.

The function should only do what is specified (note that none of these functions do any output to the screen):

1. Write a function that counts and returns the number of vowels in the string. (For the purposes of this exercise, we are talking about the standard 5 vowels -- A, E, I, O, U

(upper- or lower-case)).

2. Write a function that counts and returns the number of consonants in the string.

3. Write a function that converts the string to all lowercase.

4. Write a function that converts the string to all uppercase.

Main Program

Write a main program that performs the following steps:

1. Prompt the user to enter a string, and let them type it in.

This could be an entire sentence, with the newline indicating the end of the string. You may assume the string will be no more than 100 characters, so declare your array accordingly.

2. Display the following menu:

A) Count the number of vowels in the string
B) Count the number of consonants in the string
C) Convert the string to uppercase
D) Convert the string to lowercase
E) Display the current string
F) Enter another string
M) Display this menu
X) Exit the program

3. Enter a loop, allowing the user to type in a menu choice each time. Loop should continue until the user enters the command to exit. Upper and lowercase letters should be allowed for the menu choices. If more than one character is entered, only use the first character.

•When the A or B commands are entered (counting vowels or consonants), call the corresponding function, then print the result
•When the C or D commands are chosen, just call the appropriate function to convert the string. Do not do any output from main on these commands.
•When E is chosen, print the contents of the stored string.
•When F is chosen, allow a new string to be typed - this will replace the previous one.
•If an unknown command is entered, display the message

"Unknown Command: enter M for help"

•The menu should only be displayed once at the start, and then again whenever the M option is selected Sample Run (user input is underlined, to distinguish it from output):

Input a line of text, up to 100 characters:

> The quick brown fox jumped. The lazy dog, he was jumped over.

A) Count the number of vowels in the string
B) Count the number of consonants in the string
C) Convert the string to uppercase
D) Convert the string to lowercase
E) Display the current string
F) Enter another string
M) Display this menu
X) Exit the program

Enter your menu selection: a
Number of vowels: 16
Enter your menu selection: B
Number of consonants: 31
Enter your menu selection: c
Enter your menu selection: e

The string:

THE QUICK BROWN FOX JUMPED. THE LAZY DOG, HE WAS JUMPED OVER.

Enter your menu selection: D
Enter your menu selection: E
The string:
the quick brown fox jumped. the lazy dog, he was jumped over.
Enter your menu selection: f
Input a new line of text, up to 100 characters:
> Mary Had A Little Lamb. His name was Fleecy Pete.
Enter your menu selection: C
Enter your menu selection: e

The string:

MARY HAD A LITTLE LAMB. HIS NAME WAS FLEECY PETE.
Enter your menu selection: d
Enter your menu selection: E
The string:
mary had a little lamb. his name was fleecy pete.
Enter your menu selection: b
Number of consonants: 24
Enter your menu selection: a
Number of vowels: 14
Enter your menu selection: x
Goodbye

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92103272
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Programming Language

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As