1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SIZIF [17.4K]
3 years ago
5

You've been hired by Maple Marvels to write a C++ console application that displays information about the number of leaves that

fell in September, October, and November. Prompt for and get from the user three integer leaf counts, one for each month. If any value is less than zero, print an error message and do nothing else. The condition to test for negative values may be done with one compound condition. If all values are at least zero, calculate the total leaf drop, the average leaf drop per month, and the months with the highest and lowest drop counts. The conditions to test for high and low values may each be done with two compound conditions. Use formatted output manipulators (setw, left/right) to print the following rows:________.
September leaf drop
October leaf drop
November leaf drop
Total leaf drop
Average leaf drop per month
Month with highest leaf drop
Month with lowest leaf drop
And two columns:
A left-justified label.
A right-justified value.
Define constants for the number of months and column widths. Format all real numbers to three decimal places. The output should look like this for invalid and valid input:
Welcome to Maple Marvels
------------------------
Enter the leaf drop for September: 40
Enter the leaf drop for October: -100
Enter the leaf drop for November: 24
Error: all leaf counts must be at least zero.
End of Maple Marvels
Welcome to Maple Marvels
------------------------
Enter the leaf drop for September: 155
Enter the leaf drop for October: 290
Enter the leaf drop for November: 64
September leaf drop: 155
October leaf drop: 290
November leaf drop: 64
Total drop: 509
Average drop: 169.667
Highest drop: October
Lowest drop: November
End of Maple Marvels
Computers and Technology
1 answer:
ELEN [110]3 years ago
6 0

Answer:

#include <iostream>

#iclude <iomanip>

#include <algorithm>

using namespace std;

int main(){

int num1, num2, num3,

int sum, maxDrop, minDrop = 0;

float avg;

string end = "\n";

cout << " Enter the leaf drop for September: ";

cin >> num1 >> endl = end;

cout << "Enter the leaf drop for October: ";

cin >> num2 >> endl = end;

cout << "Enter the leaf drop for November: ";

cin >> num3 >> endl = end;

int numbers[3] = {num1, num2, num3} ;

string month[3] = { "September", "October", "November"}

for ( int i =0; i < 3; i++) {

 if (numbers[i] < 0) {

   cout << "Error: all leaf counts must be at least zero\n";

   cout << "End of Maple Marvels\n";

   cout << "Welcome to Maple Marvels";

   break;

 } else if (number[i] >= 0 ) {

     sum += number[i] ;

   }

}

for (int i = 0; i < 3; i++){

 cout << month[i] << " leaf drop: " << numbers[i] << endl = end;

}

cout << "Total drop: " << sum << endl = end;

cout << setprecision(3) << fixed;

cout << "Average drop: " << sum / 3<< endl = end;

maxDrop = max( num1, num2, num3);

minDrop = min(num1, num2, num3);

int n = sizeof(numbers)/sizeof(numbers[0]);

auto itr = find(number, number + n, maxDrop);

cout << "Highest drop: "<< month[ distance(numbers, itr) ] << endl = end;

auto itr1 = find(number, number + n, minDrop);

cout << "Lowest drop: " << month[ distance(numbers, itr1) ] << endl = end;

cout << "End of Maple Marvels";

Explanation:

The C++ soucre code above receives three integer user input and calculates the total number, average, minimum and maximum number of leaf drop per month, if the input isn't less than zero.

You might be interested in
White meat and dark meat fish have slightly different nutritional characteristics. What are the nutrition characteristics of dar
ipn [44]

The nutrition characteristics of eating darker meat of fish like Salmon are that it is higher in healthy Omega-3 fats. It is true, however, that as much as it has the highest Omega-3 fats, it is also likely to be highest in any potential toxins.






6 0
4 years ago
Read 2 more answers
Suppose that you have just bought a new computer and you want to install soft- ware on that. Specifically, two companies, which
Gennadij [26K]

Answer:

#importing the time module

import time

#welcoming the user

name = raw_input("What is your name? ")

print "Hello, " + name, "Time to play hangman!"

print "

"

#wait for 1 second

time.sleep(1)

print "Start guessing..."

time.sleep(0.5)

#here we set the secret

word = "secret"

#creates an variable with an empty value

guesses = ''

#determine the number of turns

turns = 10

# Create a while loop

#check if the turns are more than zero

while turns > 0:          

   # make a counter that starts with zero

   failed = 0              

   # for every character in secret_word    

   for char in word:      

   # see if the character is in the players guess

       if char in guesses:    

   

       # print then out the character

           print char,    

       else:

   

       # if not found, print a dash

           print "_",      

       

       # and increase the failed counter with one

           failed += 1    

   # if failed is equal to zero

   # print You Won

   if failed == 0:        

       print "

You won"  

   # exit the script

       break              

   print

   # ask the user go guess a character

   guess = raw_input("guess a character:")  

   # set the players guess to guesses

   guesses += guess                    

   # if the guess is not found in the secret word

   if guess not in word:  

 

    # turns counter decreases with 1 (now 9)

       turns -= 1        

 

   # print wrong

       print "Wrong

"    

 

   # how many turns are left

       print "You have", + turns, 'more guesses'  

 

   # if the turns are equal to zero

       if turns == 0:            

   

       # print "You Lose"

           print "You Lose

"  

7 0
3 years ago
Explain in detail, how the Depth Wavelet Transform (DWT) algorithm works, specifically with respect to EEGs (a non-invasive brai
andreyandreev [35.5K]

Electroencephalography-(EEG-) based control is a noninvasive technique which employs brain signals to control electrical devices/circuits.

This should help you

3 0
2 years ago
The top element in the hierarchy is the html element , which contains all of the other elements within a Hypertext Markup Langua
Anna [14]

the answer is true

The top element in the hierarchy is the html element

6 0
4 years ago
Install hardware, install software, and convert data are the three steps found in the _____. Select one:
aev [14]

Answer:b)Conversion plan.

Explanation:Conversion plan is type of plan in which the the technique is followed by converting the data from the present system to another system's hardware and software surroundings.

The technique follows three basic steps in the conversion plan is software installation plan, hardware installation plan and conversion of data. Thus the correct option is option(b).

3 0
4 years ago
Other questions:
  • 1. Which of the following might be a problem taken on by environment engineers?
    8·1 answer
  • What is intellectual property?
    7·1 answer
  • Write a Java program that can compute the interest on the next monthly mortgage payment. The program reads the balance and the a
    12·1 answer
  • What short (two letters!) but powerful boolean operator can check whether or not one string can be found in another string?
    12·1 answer
  • Although the traditional model of software acquisition still accounts for more software acquisition, a new model, called _______
    7·1 answer
  • When a module is executing what happens when the end of the module is reached?
    10·1 answer
  • Plz answer me will mark as brainliest​
    8·1 answer
  • Your manager has requested you keep a timesheet showing how many hours you work each day and what projects you work on during th
    13·2 answers
  • I’ll mark who ever is first or last Doesn’t matter JUST PLEASE HELP
    8·1 answer
  • NEED HELP ASAP
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!