Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help please

Help please

Scheduled Pinned Locked Moved C / C++ / MFC
c++rubycomdata-structureshelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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 rthe 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. I can you you my code so far if you need it. 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 gmathes@mmcable.com

    C L 2 Replies Last reply
    0
    • L Lost User

      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 rthe 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. I can you you my code so far if you need it. 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 gmathes@mmcable.com

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Hi - congratulations on the little one. Is it your first ? My wife is cooking our third at the moment. It would be helpful to see your code, so we can see how far you've got and where you need help. As far as the second program goes, it's simply a case of using cin >> to get the string ( which will be a char array ), passing the address of the first character into the function, using a while loop ( I guess, or you could use strlen to find out the size, but that defeats the purpose of counting it yourself ) to step through the array from that point. You have to use a pointer, so you'd want to pass in a char pointer and use pointer arithmetic to increment it ( pChar++ ) until it equals NULL ( NULL, '\0' or 0, they are synonymous ). I don't see why you'd return the character if it's always NULL, I think you mean the character count. So set an int to zero, increment it in the loop and return that value. If you post your code for both problems ( I've not addressed the first on the basis you've got a start so you should post the code first ), then I'll be glad to comment further. Christian As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet. Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.

      A 1 Reply Last reply
      0
      • C Christian Graus

        Hi - congratulations on the little one. Is it your first ? My wife is cooking our third at the moment. It would be helpful to see your code, so we can see how far you've got and where you need help. As far as the second program goes, it's simply a case of using cin >> to get the string ( which will be a char array ), passing the address of the first character into the function, using a while loop ( I guess, or you could use strlen to find out the size, but that defeats the purpose of counting it yourself ) to step through the array from that point. You have to use a pointer, so you'd want to pass in a char pointer and use pointer arithmetic to increment it ( pChar++ ) until it equals NULL ( NULL, '\0' or 0, they are synonymous ). I don't see why you'd return the character if it's always NULL, I think you mean the character count. So set an int to zero, increment it in the loop and return that value. If you post your code for both problems ( I've not addressed the first on the basis you've got a start so you should post the code first ), then I'll be glad to comment further. Christian As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet. Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.

        A Offline
        A Offline
        A R 0
        wrote on last edited by
        #3

        Hey! congratulations for your third !!! Is always a bless :)

        C 1 Reply Last reply
        0
        • A A R 0

          Hey! congratulations for your third !!! Is always a bless :)

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Thanks. It was not planned, but I'm realy stoked about it. Christian As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet. Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.

          C 1 Reply Last reply
          0
          • C Christian Graus

            Thanks. It was not planned, but I'm realy stoked about it. Christian As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet. Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.

            C Offline
            C Offline
            Carlos Antollini
            wrote on last edited by
            #5

            Hey Christian, Congratulations, Always is good to read about you. Cheers!!! :-D Carlos Antollini.

            1 Reply Last reply
            0
            • L Lost User

              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 rthe 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. I can you you my code so far if you need it. 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 gmathes@mmcable.com

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              here is the code so far, i am so stuck, this is my third and he was two months premie... I got the psuedocode from another studend bt do not know what to do, all my teacher will say is read the book and that is no help // # Include # include 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 = accumu

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups