Thread: Assistance in a walkthrough of a lab

  1. #1
    Registered User
    Join Date
    Mar 2015
    Posts
    5

    Assistance in a walkthrough of a lab

    *Hello, i'm relatively new to Structured Programming C++ and my teacher is throwing us into the deep end with this lab. I only have an understanding of the basics, so i'm not doing well in understanding this lab. I've defined a few things that I think i'll need in my program, but that's it. If you could help, it'd be much appreciated. Thank you.*

    Lab: You are to develop a program that will determine what time zone random samplings of residents live. The 4 choices of course are Eastern (E), Central (C), Mountain (M), and Pacific (P) Time zones.

    The report you produce will show the total number of residents in each time zone, and the associated %age.

    You will need to determine the best looping mechanism to handle ANY amount of input.

    You design the output report. Make it professional looking and formatted.

    Be sure to show %ages with 2 decimals.

    Be sure to turn in source code and output. Test your program appropriately. (E.g. what if no one lived in one or more of the time zones).

    Lastly, write this program 2 ways – one with CASE and one way with IF/Else flow of control. Tell me which way you prefer, and why?

    *Below is what I have so far.*

    #include <iostream>
    #include <iomanip>
    using namespace std;
    int main ()
    {
    // Assignment 4: Part 1: U.S. Residency Report

    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

    int E; //Eastern Time Zone
    int C; //Central Time Zone
    int M; //Mountain Time Zone
    int P; //Pacific Time Zone
    double residents;
    double age;
    double total_residents; //Total number of residents in each time zone
    double percent_age; //Associated percent age

    cout << "\n\n\n\n\n\n\n\n\n";

    cout << right << setw(45) << "Enter a random number of residents: ";
    cin >> residents;

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So what is your question(s), exactly? If we don't know what you're confused about, we can't help.
    Also use code tags for code, like so: [code]my code[/code].
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Mar 2015
    Posts
    5
    My apologies Elysia. I know it's a lot, and nobody here owes me anything, but I'm basically asking for some help in making this program. I stated above that my professor sort of just threw my class and I out into the deep end with this lab and me being new to Structured Programming C++ am struggling with it.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You did mention that, and we're willing to help, but again, I don't know what part you're having problems with?
    Is it the input? Are you having trouble with how to read a value? How to deal with errors? How to deal with (possibly) unlimited input?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  6. #6
    Registered User
    Join Date
    Mar 2015
    Posts
    5
    I'm pretty much having trouble with this whole assignment. I know what it is I have to do, i'm just not sure how to do it. I'm not asking anyone to do the whole thing, I'm asking for a walkthrough of it so that I can learn and hopefully do it on my own the next time.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Xefin View Post
    I'm pretty much having trouble with this whole assignment. I know what it is I have to do, i'm just not sure how to do it. I'm not asking anyone to do the whole thing, I'm asking for a walkthrough of it so that I can learn and hopefully do it on my own the next time.
    Do you know how to write and use a C++ function?

    FYI: We can NOT help you without you asking a real question because we have no idea of what you know and what you are supposed to know.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Mar 2015
    Posts
    5
    I do, it's just this lab in particular. Our professor hardly teaches but i've been able to mostly get by with the work we've gotten so far. However, with this assignment here he kind of just dropped it on us from out of nowhere with no teaching to even help prepare us for it.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Explain to us what you've been able to accomplish and what you're not so sure about.
    Break your program down into components such as reading user input, calculating the data and outputting the data. Then divide that into the steps required to perform those actions and tell us how you would attempt to implement them, or if you don't know, ask about what you're unsure of. Make attempts. If you're unsure, just ask for a general approach. But you can't us for a solution to the whole problem. We can guide you on the WAY to solving problems, like tell you what kind of loop you might need or how to fix the input stream going into an error state, etc.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Mar 2015
    Posts
    5
    I've been researching and looking up possible steps that might aid me in this lab but have found nothing. I'll continue to give it a try and ask any questions that I may have with it.

    Just know that I don't expect a whole answer from anyone, i'm hoping for a step-by-step walk through of the lab.

    If I were to get a running start, I can then go off of that and hopefully get little by little accomplished coming here with any small questions I might have down the line, that's all.

    Thanks.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Xefin View Post
    I've been researching and looking up possible steps that might aid me in this lab but have found nothing. I'll continue to give it a try and ask any questions that I may have with it.
    Just think about it: if you were tasked to do this in real life, how would you do it?
    First do a very coarse overview, then think about how to do it in smaller steps.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12

  13. #13
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    It sounds as if you will need to sort the values based on the rangethey are in, rather than an absolute value. This will require iterating through the list of residences time values. There should only ever be 4 values. So basically you need to write a program than can sort any range of 4 numbers as well as any other range.

    If you were to iterate through the list, then take and add the minimum and maximum values, then divide them by 2, you would have divided the time-zones of the country geographically in half. Once you have all the time zone values, just restart the list iteration, comparing the values you see to the ones you have gotten from the loop before, and store all values in the appropriate array.
    WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. in need of a little assistance
    By unknown2007 in forum C Programming
    Replies: 8
    Last Post: 11-02-2011, 07:05 AM
  2. help with walkthrough
    By Thegame16 in forum C++ Programming
    Replies: 1
    Last Post: 04-18-2011, 10:36 PM
  3. mental walkthrough
    By Chaplin27 in forum C++ Programming
    Replies: 2
    Last Post: 12-20-2004, 01:59 PM
  4. Peasant's Quest Walkthrough
    By sean in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 09-25-2004, 06:46 AM
  5. Walkthrough`
    By Programmer2b in forum C Programming
    Replies: 1
    Last Post: 04-25-2002, 08:46 PM

Tags for this Thread