NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

///////////////////////////////////////////////////////////////////////////////
//
// Name: FILE-NAME-GOES-HERE
// Author: AUTHOR-NAME GOES HERE
// Course: CMPSC 101/121
// Purpose: DESCRIPTIVE-PURPOSE-GOES-HERE.
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// Header Files...
///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>

///////////////////////////////////////////////////////////////////////////////
// Namespaces used....
///////////////////////////////////////////////////////////////////////////////
using namespace std;

///////////////////////////////////////////////////////////////////////////////
// Function Prototypes....
///////////////////////////////////////////////////////////////////////////////
void pause();
int processing (double balloon[]);
string inputName();
double inputBalloon();
void balloonStorage(double balloon[]);

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: inputName
// PARAMETERS: None
// RETURN TYPE: string
// PURPOSE: To take the name of the person as input
//
///////////////////////////////////////////////////////////////////////////////

string inputName()
{
string name;
cout << "Please enter your name: ";
cin >> name;
return name;
}

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: inputBalloon()
// PARAMETERS: None
// RETURN TYPE: double
// PURPOSE: To take input of individual volume and check if greater than 0
//
///////////////////////////////////////////////////////////////////////////////


double inputBalloon()
{
double b;
cin>>b;
if(b>0) //Checks if the volume is greater than 0
return b;
else //Otherwise lets the user input it again.
{
cout<<"Enter the volume greater than 0"<<endl;
inputBalloon();
}
}
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: balloonStorage
// PARAMETERS: An array of double data type
// RETURN TYPE: none
// PURPOSE: To store the individual volume values in an array
//
///////////////////////////////////////////////////////////////////////////////

void balloonStorage(double balloon[])
{
cout << "Please enter 5 balloon volumes (in cubic inches) separated by spaces:"<<endl;
for (int i =0; i<5; i++)
balloon[i] = inputBalloon(); //Calls function inputBalloon to get input and stores it in the array elements
}

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: processing
// PARAMETERS: An array of double data type
// RETURN TYPE: int
// PURPOSE: Counts the actual number of balloons with exceeding volumes
//
///////////////////////////////////////////////////////////////////////////////


int processing (double balloon[])
{
int counter=0; //Initializes a count variable to 0
for (int i = 0; i < 5; i++) //Runs the loop 5 times for 5 elements of the array
{
if (balloon[i] > 120.30) //Checks if condition
{
counter++; //Increments counter if the condition is true
}
}
return counter; //Returns the count of the numbers
}

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: main
// PARAMETERS: none
// RETURN TYPE: int
// PURPOSE: Entry for the program
//
///////////////////////////////////////////////////////////////////////////////

int main()
{
double vol;
double balloon[5]; //Declares an array of double type of size 5
string name;
// Code statements go here...
name = inputName(); //Takes input the name of the user and stores it in a string "name"
balloonStorage(balloon); //Takes input of the 5 values of volumes for the balloons
int counter = processing(balloon); //Stores the number of balloons with exceeding volumes in an integer called "counter"
cout<<name<<" - " <<counter<<" of your balloons exceed(s) the maximum volume of 120.30 cubic inches and therefore must have popped!";

/*
NOTE: Do not modify the main() function below this line...
*/

// pause the program...
pause();

// exit the program with success (0 == success)
return 0;
}

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: pause
// PARAMETERS: None
// RETURN TYPE: void
// PURPOSE: Causes the program to wait before moving on.
//
///////////////////////////////////////////////////////////////////////////////

void pause()
{
// flush the buffer...
cin.sync();
// alert the user...
cout << "nPress any key to continue...n";
// get the next character...
cin.get();
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.