"how to write int menu () function in c++" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "how to write int menu () function in c++" answered properly. Developers are finding an appropriate answer about how to write int menu () function in c++ related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like how to write int menu () function in c++. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on how to write int menu () function in c++. 

how to write int menu () function in c++

By Modern MongooseModern Mongoose on Mar 12, 2021
//Matthew Beard
//Program 3

#include <iostream>
#include <iomanip>
using namespace std;

//Functions
void showWelcome();
void showMenu();
int showSpring();
int showSummer();
int showFall();
int showWinter();



int main()
{
    int choice;     //menu choice
    
    
    //constants for menu choices
    const int SPRING_CHOICE = 1,
              SUMMER_CHOICE = 2,
              FALL_CHOICE = 3,
              WINTER_CHOICE = 4,
              QUIT_CHOICE = 5;
    
    cout << fixed << showpoint << setprecision(1); //sets to 1 decimal place
    
    do
    {
         showWelcome(); // Show Welcome screen
         showMenu(); // Display Menu
         cin >> choice;
         
         //Validate menu selection
         while (choice < SPRING_CHOICE || choice > QUIT_CHOICE)
         {
               cout << "Please enter a valid menu choice: ";
               cin >> choice;
         }
         
         //If user does not want to quit, proceed.
         if (choice != QUIT_CHOICE)
         {
                    switch (choice)
                    {
                           case SPRING_CHOICE:
                                int showSpring();
                                break;
                           
                           case SUMMER_CHOICE:
                                int showSummer();
                                break;
                                
                           case FALL_CHOICE:
                                int showFall();
                                break;
                           
                           case WINTER_CHOICE:
                                int showWinter();
                                break;
                    }
         }
         } while (choice != QUIT_CHOICE);
         return 0;
}
//Welcome Function
void showWelcome()
{
     cout << "Welcome to the average rainfall calculator" << endl << endl;
     system ("pause");
}

//Menu Function

void showMenu()
{    
    cout << "Please choose a season" << endl << endl
         << "1. Spring" << endl
         << "2. Summer" << endl
         << "3. Fall" << endl
         << "4. Winter"<< endl 
         << "5. Quit" << endl << endl;
}
    
//Spring choice function

int showSpring(float spring, float spring1, float spring2, float spring3)
{
    cout << "Enter the rainfall for month one " << endl;
    cin >> spring1;
    cout << endl << "Enter the rainfall for month two " << endl;
    cin >> spring2;
    cout << endl << "Enter the rainfall for month three " << endl;
    cin >> spring3;
    spring = (spring1 + spring2 + spring3) / 3;
    cout << endl << "The average rainfall for Spring was "
         << spring << endl << endl;
    return 0;
}

//Summer choice function

int showSummer(float summer, float summer1, float summer2, float summer3)
{
    cout << endl << "Enter the rainfall for month one " << endl;
    cin >> summer1;
    cout << endl << "Enter the rainfall for month two " << endl;
    cin >> summer2;
    cout << endl << "Enter the rainfall for month three " << endl;
    cin >> summer3;
    summer = (summer1 + summer2 + summer3) / 3;
    cout << endl << "The the average rainfall for Summer was "
         << summer << endl << endl;
    return 0;
}

//Fall choice function

int showFall(float fall, float fall1, float fall2, float fall3)
{
    cout << endl << "Enter the rainfall for month one " << endl;
    cin >> fall1;
    cout << endl << "Enter the rainfall for month two " << endl;
    cin >> fall2;
    cout << endl << "Enter the rainfall for month three " << endl;
    cin >> fall3;
    fall = (fall1 + fall2 + fall3) / 3;
    cout << endl << "The average rainfall for Fall was "
         << fall << endl << endl;
    return 0;
}

//Winter choice function

int showWinter(float winter, float winter1, float winter2, float winter3)
{
    cout << endl << "Enter the rainfall for month one " << endl;
    cin >> winter1;
    cout << endl << "Enter the rainfall for month two " << endl;
    cin >> winter2;
    cout << endl << "Enter the rainfall for month three " << endl;
    cin >> winter3;
    winter = (winter1 + winter2 +winter3) / 3;
    cout << endl << "The average rainfall for Winter was "
         << winter << endl << endl;
    return 0;
}

Source: www.cplusplus.com

Add Comment

0

All those coders who are working on the C++ based application and are stuck on how to write int menu () function in c++ can get a collection of related answers to their query. Programmers need to enter their query on how to write int menu () function in c++ related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to write int menu () function in c++ for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of how to write int menu () function in c++ while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "how to write int menu () function in c++". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to write int menu () function in c++ resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "how to write int menu () function in c++"

View All C++ queries

C++ queries related to "how to write int menu () function in c++"

how to write int menu () function in c++ I need to write an int function in which there are only cout statements and if I return 0/1 it prints them too. how to write int variable c++ invalid types int int for array subscript c++ can we compare a long long int with int in c++ using max or min functions the statement vector vector int matrix(100 vector int (50 100) ) declares function to write a string in loercase in c++ Write a function called clean that takes a C++ string as input and removes any characters in the string that are not letters except for space blanks. Write a function called max_size that takes a vector of strings as an input and returns the string with the maximum length. function return with int c++ c++ menu selection with arrow keys menu driven program to delete in linked list how to use a non const function from a const function passing function to another function in c++ c++ convert template function to normal function The syntax to decexample of a function declarationlare a function is: pass a value to the function parameter while calling the function how to write an or in c++ how to read and write in a file c++ how to write something in power of a number in c++ write in file cpp write and read string binary file c++ Write a program to find the sum of all sub-arrays of a given integer array. write a program to implement stack using array how to write hello world c++ Write a program to print following pattern; 1 1 2 1 2 3 1 2 3 4 c++ code to write 2d array how to write C++ list ++ how to write quotation mark in a string how to write a template c++ how to write a class in c++ Write a program that inputs test scores of a student and display his grade fstream read write mode write to file in C++ c++ write string What is the meaning of inheritance in C++. Write an example of simple inheritance. Write a program to sort an array 100,200,20, 75,89.198, 345,56,34,35 using Bubble Sort. The program should be able to display total number of passes used for sorted data in given data set. Write a C++ program using class and objects. You have to define multiple-member functions outside class and all those functions will be the same name Write a c++ loop to read n characters from the keyboard and store them in the vector v. "how we write a program for" time swap" in c plus plus only with string" Write a loop to read n strings (containing no white space) from the keyboard and store them in the vector v. Given the following declarations below. Write a loop to read a list of numbers from the keyboard terminated by -999 and store the even numbers (skip over the odd numbers) in the vector v. Write a c++ program to print number triangle. visual studio 2019 read and write text file c++ how to write a conclusion statement for an informative essay c++ write to file in directory Write a program that inputs time in seconds and converts it into hh-mm-ss format c++ write to csv file append Write a c++ program that reads a sentence (including spaces) and a word, then print out the number of occurrences of the word in the sentence write a program that simulates the rolling of two dice in c++ write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings Write a program to implement Liang-Bersky line clipping algorithm Write a program in C++ to find post-order predecessor of a node in a Binary Tree how to set a range for public int or float unity how to make sure the user inputs a int and not anything else c++ int range in c++ 14 unordered_map of pair and int change int to string cpp cpp float to int what is order in of preeendence in float, int, char, bool convert stirng to int c++ map of int and vector syntax c++ parse int string to int in c++ how to ensure the user inouts a int and not anything else c++ c++ round to int double to int c++ convert int to binary string c++ c++ loop through int array how to convert int to string c++ difference between unsigned and signed int c++ char to int c++ convert a int to string c++ initialize int c++ int to float c++ cpp random int int random string generator c++ how to cast int c++ c++ int to string how to convert from string to int in c++ string to int c++ concatenation cpp int and stirng int to hexadecimal in c++ maximum int c++ char* to int in cpp length of int c++ int max in c++ convert string to int c++ convert long int to binary string c++ C++ int to char* c++ string to vector int c++ get maximum value unsigned int int to string c++ c++ min int how to convert int to std::string c++ convert const char* to int string hex to int c++ why return 0 in int main how to turn int into string c++ c++ random int troll c++ convert int to cstring error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive] convert char to int c++ c++ convert int to double entering char in int c++ avoid loop the number of ones int bitset ue4 int to enum c++ what does static int do? c++ optimize big int array long long int range c++ can you add a bool and an int convert int to string c++ c++ cout int converting char to int in c++ c++ length of int #include using namespace std; int main() { double leashamt,collaramt,foodamt,totamt; cout c++ string to int int to char in c++ convertir string a int c++ how to use python sleep function on c++ sine function in cpp find function in c++ how to use winmain function reverse string efficient in cpp without using function sum of 2 numbers in cpp function reference function in c++ c++ sleep function 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS time function c++ return array from function c++ c++ main function c++ sort function time complexity how to get name of caller function c++ c++ template function gcd function in c++ define my own compare function sort C++ stl c++ callback member function function call in c++ friend function in c++ how to declare a function in c++ z function cp algorithm factorial c++ without using function c++ function overload what is time complexity of swap function insert function in c++ vector pure virtual function in c++ function template How to make a function in C++ built in function in c++ for binary to decimal binary search function in c++ is it len function is aviable for c+= function in c++ function in struct c++ euler's totient function c++ stack function in cpp passing array to function c++ pointer sqrt() function in c++ how to return an array from a function count function c++ clear function in vector reverse string in c++ without using function next_permutation function in c++ c++ function default argument inline function in c++ standard deviation function in c++ what does compare function do in c++ sort function in cpp cpp lambda function how to modify 2d array in function c++ template function in C++ calling base class function from derived class object c++ passing vector to function Function pointer C++ quick sort predefined function in c++ c++ round function function declerations in C++ c++ function to find length of array sleep system function linux c++ sort inbuilt function in c++ cpp function takes in vector friend function cpp reference thread c++ member function function for searching in map in c++ how to make a function in cpp virtual function in c++ how to declare function with multiple parameter c++ cpp function that returns two arguments C++ invalid use of 'this' outside of a non-static member function of c++ bind class member function & before function arg in cpp accepting multiple values from a function in cpp launch function with signal c++ function overriding in oop c++ c++ strict function return checking decimal to binary predefined function c++ check source code function return stl function to reverse an array map at function c++

Browse Other Code Languages

CodeProZone