• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

c++ programming challenge help

galenda

Junior Member
I am in a beginning C++ class and just had a baby, I am finally home but I am two coding projects behind
can someone please give me an assist and explain it to me please...
here are the two assignments :

page 621 or 667 (3rd edition) starting out with C++ by tony gaddis

write a program that uses a structure to store the following wather information for a particular month:
Total Rainfall
High Temperature
Low Temperature
Average Temperature

The program should have an array of twelve structures to hold weather information for an entire year.
When the program runs, it should ask the user to enter data for each month. (the average temp should be calculated).
Once the data is entered for all the months, the program should calculate and display the average monthly rainfall, the total rainfall for the year, the highest and lowest tempretures for the year (and the monthes they occured in), and the average of all the monthly average temps.
input validation: only temps within the range of -100 and 140 degrees F.

the second assignment asks the user to input a sentence at the keyboard.
Passs the string to a function using a loop and pointer to inspect all characters in the string untill it finds a null character.
the function should then return the charater to main(). The function manin() should print the character count to the screen.

any help would be greatly appreciated.
galenda
Ruby.Mathes@tinker.af.mil


here is what I have so far, help please

# Include <iostream.h>
# include <string.h>

struct weather

{
char month[12];
float total_rainfall;
float high_temp;
float low_temp
float average_temp:
};

Void main ()
{
weather year [12]
{"January", 0.0, 0.0, 0.0, 0.0},
{"February", 0.0, 0.0, 0.0, 0.0},
{"March", 0.0, 0.0, 0.0, 0.0},
{"April", 0.0, 0.0, 0.0, 0.0},
{"May", 0.0, 0.0, 0.0, 0.0},
{"June", 0.0, 0.0, 0.0, 0.0},
{"July", 0.0, 0.0, 0.0, 0.0},
{"August", 0.0, 0.0, 0.0, 0.0},
{"September", 0.0, 0.0, 0.0, 0.0},
{"October", 0.0, 0.0, 0.0, 0.0},
{"November", 0.0, 0.0, 0.0, 0.0},
{"December", 0.0, 0.0, 0.0, 0.0},
float total_year rain=0
float accumulated_avgtemp=0
float highest_temp=-100
float lowest_temp=140
char calender[12][10]
};

for (int x = 0; x < 12; x++)
{
cout << "Please enter the following
data for " << month[x]<< ": \n\n";
cout << "High temperature: ";
cin >> month[x].high_temp;
cout << "Low temperature: ";
cin >> month[x].low_temp;


psudocode for the rest so far
Prompt user for data entries for the month of calendar[a]:

Input total_rain
If total_rain is less than zero, prompt user for re-entry and loop back to input.
Add total_rain to accumulated_yearly_rain.

Call Function One (get_temp)
Return new value for high_temp.
Call Function One (get_temp)
Return new value for low_temp.
If high_temp is less than low_temp, prompt user for
re-entry and loop back to first call of Function One.
Calculate average_temp for the month using high_temp and low_temp.
Add average_temp to accumulated_average_temp.
If high_temp is higher than overall_high_temp
then replace overall_high_temp with high_temp.
If low_temp is higher than overall_low_temp
then replace overall_low_temp with low_temp


Output the following:

Average Monthly Rainfall = accumulated_yearly_rain / 12
Yearly High Temp = overall_high_temp
Yearly Low Temp = overall_low_temp
Average Temperature = accumulated_average_temp / 12
Average Total Yearly Rainfall = accumulated_yearly_rain

Begin Function One
(zero arguments, one return)

Define local float temp = 0

Prompt user to input temp.
If temp is not within standard range,
prompt user for re-entry and loop back to input.

Return temp to main.

thanks again
galenda
ruby.mathes@tinker.af.mil
 
Back
Top