The menu
Here is what the menu should look like when running your program:
***********************************
* FUN MENU *
***********************************
<S>um of natural integers
<L>eap year check
<C>ount vowels
<E>xit
Menu tasks
The following definition is how to verify if a year is a leap year taken from Wikipedia.org:
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the years 1600 and 2000 are. For more information feel free to go to: Leap Year Info (외부 사이트로 연결합니다.)
Note: to get full credit you must use if else statements, not multiple if statements. Read the leap year definition carefully before coding. I will look for efficiency in your if else logic. Less efficient code may get deductions. Remember there aren't many leap years in life so quickly ruling out non-leap years is a good tactics.
Main function's implementation requirements
---------------------------------------------------------------------------------------------------------------------------
NOTE: For all input readings that use getline function (Counting Vowels is one) you may need to flush the input stream (still containing left over characters from previous input/keyboard operations) prior to invoking getline by placing the following code just before the getline statement:
if (cin.peek ( ) == '\n')
cin,ignore ( ); // flush the '\n' character from input stream
// now use getline to read the entire line including spaces
----------------------------------------------------------------------------------------------------------------------------
Make this for me!
C++ Program:
#include <iostream>
#include <cstdlib>
using namespace std;
//Function that computes sum of N numbers
void sumN()
{
int n, i, sum=0;
//Reading a NUMBER
cout << "\n Enter a number: ";
cin >> n;
//Looping
for(i=1; i<=n; i++)
{
//Accumulating sum
sum = sum + i;
}
//Printing sum
cout << "\n Sum of " << n << " natural numbers: "
<< sum << " \n";
}
//Function that checks for leap year
void leapYearCheck()
{
int year;
cout << "\n Enter Year: ";
cin >> year;
// Exactly divisible by 400
if (year%400 == 0)
cout << year << " is a leap year.\n";
// Exactly divisible by 100 and not by 400
else if (year%100 == 0)
cout << year << " is not a leap year. \n";
// Exactly divisible by 4 and neither by 100 nor 400
else if (year%4 == 0)
cout << year << " is a leap year.\n";
// Not divisible by 4 or 100 or 400
else
cout << year << " is not a leap year. \n";
}
//Function that counts vowels
void countVowels()
{
string str;
int cnt=0, i;
//Reading string from user
cout << "\n Enter a string: ";
if (cin.peek ( ) == '\n')
cin.ignore ( ); // flush the '\n' character from input stream
getline(cin, str);
//Iterating over each character
for(i=0; i<str.length(); i++)
{
switch(str[i])
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U': cnt += 1; break;
}
}
cout << "\n\n Total number of vowels: " << cnt <<
"\n";
}
//Function that prints the menu
void menu()
{
cout << "\n *********************************** ";
cout << "\n * FUN MENU *";
cout << "\n *********************************** ";
cout << "\n \t <S>um of natural integers \n\t
<L>eap year check \n\t <C>ount vowels \n\t
<E>xit\n";
}
// Main function
int main()
{
char ch;
while(1)
{
//Printing menu
menu();
cout << "\n Enter your choice: ";
cin >> ch;
//Calling respective function
switch(ch)
{
case 'S':
case 's': sumN(); break;
case 'L':
case 'l': leapYearCheck(); break;
case 'C':
case 'c': countVowels(); break;
case 'E':
case 'e': cout << "\n The fun is over. Have a nice day!!!
\n"; exit(0);
}
}
return 0;
}
___________________________________________________________________________________________________
Sample Run:


The menu Here is what the menu should look like when running your program:  
JAVA CODE Beginner. please use if, else if or switch statements, but don't use arrays, please Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12...
Write a C program that does the following: • Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square, Diamond (with selected height and selected symbol), or Quits if user entered Q. Apart from these 2 other shapes, add a new shape of your choice for any related character. • Program then prompts the user to...
CIS22A Homework 6 Topic: Chapter 4 & 5 Purpose: Determine if a year is a leap year Create a new C++ project titled “HW 6” in the CodeBlocks IDE. Use the “Console Application” project option. Over time, the calendar we use has changed a lot. Currently, we use a system called the Gregorian Calendar and it was introduced in 1582. The algorithm to determine if a year is a leap year is as follows: Every year that is exactly divisible...
#1 Write a MATLAB script to solve: Leap Year Program (practice your IF statements!) Write a code to determine if a year is considered a leap year or not? Display to the screen if the year is a leap year or not. Use num2str() and display() or fprintf(). In the Gregorian calendar three criteria must be taken into account to identify leap years: The year is evenly divisible by 4 (Exceptions 1700, 1800, and 1900); If the year can be...
Write a program in Python that will: Here are following requirements to completing Menu shapes: 1. Create a "MENU" with 4 - 5 options have the user click the option and thereafter ask the user to enter the amount of stars from 1 - 50. From there your "for loop" will create the shape. Menu options need to be: 1. Filled Triangle 2. filled Square 3. This can be any shape such as a Square, circle, a different angle of...
Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...
Write a Java Program that performs the following functionalities: and you can use if statements, cases, and string methods Enter a new main sentence Find a String Find all incidents of a String Find and Replace a String Replace all the incidents of a String Count the number of words Count a letter’s occurrences Count the total number of letters Delete all the occurrences of a word Exit The program will display a menu with each option above, and then...
Topics c ++ Loops While Statement Description Write a program that will display a desired message the desired number of times. The program will ask the user to supply the message to be displayed. It will also ask the user to supply the number of times the message is to be displayed. It will then display that message the required number of times. Requirements Do this assignment using a While statement. Testing For submitting, use the data in the...
Extend this date validation program, so that it checks for valid
leap years (in which the month February has 29, instead of 28,
days). A leap year is any year that is divisible by 4 but not
divisible by 100, unless it is also divisible by 400. Do not allow
February to have 29 days on years that are not leap years.
**Please view both photos for the entire code and post new code
with the leap year modification. Thank...
Textual menus work by showing text items where each item is numbered. The menu would have items 1 to n. The user makes a choice, then that causes a function to run, given the user made a valid choice. If the choice is invalid an error message is shown. Whatever choices was made, after the action of that choice happens, the menu repeats, unless the menu option is to quit. Such kind of menus are displayed from the code under...