Jump to content
  • Advertisement

Blckknight118

Member
  • Content Count

    67
  • Joined

  • Last visited

Community Reputation

124 Neutral

About Blckknight118

  • Rank
    Member
  1. Blckknight118

    Help with reading from a file

    I found it out but please explain to me how you change one variable for it to work. void DETERMINE(ifstream& inputFile, int& y, int& z) { int number = 0; inputFile >> z; while (inputFile >> number) { if(z > number) { z = number; } else if(y < number) { y = number; }
  2. Blckknight118

    Help with reading from a file

    Quote:Original post by Palidine Step through it in your debugger with a simple input file. The bug should be obvious straight away. -me I'm not sure how to do a Visual Studio step by step process using the debugger. And this will be my last time abusing these forums. I'll just keep working even if I don't understand it.
  3. Blckknight118

    Help with reading from a file

    Quote:Original post by Erik Rufelt If y is smaller than the new number, set y to the new number. If y is larger than the new number, set z to the new number. What do you think that algorithm does? It seems you post a new message here every week about a homework problem, and then disappear. Did you read all the responses in your last thread? Doing an assignment in one day once a week is not a good way to learn programming. Get a book, or follow an online tutorial, and do it a couple of hours at least several days a week, and it will get easier quite fast. It's often easier if you get a simple goal, such as doing a text-based game or something, and learn things that you need to make that happen. If you don't have time because of studies or something, at least try to do the assignments over the course of a few days. This is a lab assignment but your suggesting I do random programs every day to get better? Also, the algorithm reads through the whole file and if y < number then y = number which basically goes to one number and if that number is bigger than the previous than y becomes that number. It's similar as y except it should search for the lowest number.
  4. Blckknight118

    Help with a homework problem

    Quote:Original post by szecs "My professor assigned us a Lab and basically didn't explain to any of us how to figure it out" Oh, how cruel he is. I can imagine that he doesn't even hold your hand when you cross the street. This world is soooo cruel I tell you. Sarcasm isn't needed
  5. Blckknight118

    Help with a homework problem

    I'll try for a little bit longer. If I don't figure it out, I'm just gonna take another F. Thanks for the help from the people who posted in this thread.
  6. Blckknight118

    Help with a homework problem

    I don't know how I could get this: cout << " 1 2 3 4 5 6 7 " << endl; cout << " 8 9 10 11 12 13 14 << endl; cout << " 15 16 17 18 19 20 21" << endl; cout << " 22 23 24 25 26 27 28" << endl; cout << " 29 30 31" << endl; using a loop
  7. Blckknight118

    Help with a homework problem

    Quote:Original post by Erik Rufelt Don't try to learn arrays or anything else not covered in your class yet. This is an extremely easy task, at least the first week part, and much easier than the last one you posted about last week. You seem to have a mental block. Don't get stuck on knowing everything or making it perfect, just use what you know and make it as good as you can and turn it in, and your professor will teach you how to do it better. You can start with the following tasks, which I'm sure isn't hard for you. Draw 7 days: Option1: cout << "1 2 3 4 5 6 7"; Option2: for(int i=1;i<=7;++i) cout << i << " "; Draw 6 days: Option1: cout << "1 2 3 4 5 6"; Option2: for(int i=1;i<=6;++i) cout << i << " "; Draw n days: implement this yourself Draw 7 days, starting at 20: Option1: cout << "20 21 22 23 24 25 26"; Option2: implement this yourself Draw n days starting at x: implement this yourself You already showed that you know how to calculate the number of days in the first week. So create a program that prints the first week. Don't wait until you know how to solve the whole thing, just create that first part. There are exactly 7 different inputs (0, 1, ...6), so you have exactly 7 possible different versions of the January calendar. Type all these 7 different calendars by hand, then run your program for the 7 different inputs, and compare the first row of the handwritten calendars to the 7 outputs of your program. When you get 7 matches, your program that prints the first week is complete. Then expand your program to two weeks, and make sure all 7 match up. Continue until January is done. At that point you should be able to implement February on your own. I don't understand, when does the offset come into place. I can print the days of 1 week fine using a for loop, but I don't know what you mean when you saw draw n days starting at x. Is this what you mean? for(int i=20; i<=26 i++) cout << i << " "; or this for(int i=1 i<=7 i++) for(startingday<=26 days++) cout << startingday << " "
  8. Blckknight118

    Help with a homework problem

    Quote:Original post by Erik Rufelt Quote:Original post by Blckknight118 Help.....please What do you need help with? Did you write the program that prints the first week yet? Did you write the program that prints the first month? That's the thing, I don't know how I would print the offset correctly....I know I would use a for loop...I think and somewhere there would be a cout << " " to space in between the numbers.
  9. Blckknight118

    Help with a homework problem

    Quote:Original post by FritzMar what language are you learning? in general arrays are like a container of a fixed size think like a dresser each draw contains one value most array systems the first element is 0 so if you want to look at the top drawer it would be drawer 0, then drawer 1, then drawer 2 so in this case if we had an array of months we know that January is the first month that would be month 0 in our array and would contain the value 31 for the number of days you can then use a for loop and the iterator from that loop to adjust the number of days in each month with out needing to have a section for each month to draw it I'm learning C++ So basically an array would be like Months of year[]= {0,31,28,31,30,31,30,31,31,30,31,30,31} ??
  10. Blckknight118

    Help with a homework problem

    Help.....please
  11. Blckknight118

    Help with a homework problem

    Quote:Original post by FritzMar i think the goal of this assignment is to help you use nested loops and arrays to help you draw a calendar. so what we've already helped you break down what information you might need the only odd bit of information passed is the leapyear info and you might get extra credit for it use an array to store the number of days in each month or you can use predefined values for it your choice one method is more difficult in the end then the other then you are going to need to draw the days of each week and format them pushing them to the left so that they may line up with something like the days of the week if you are going to draw them then you are going to need to remember the offset for the end of each month that offset is the key to being able to draw each month there should also be a system function to help you determin if a given year is a leap year or not i know there is something for linux so windows and mac osx should also have something similar I don't know how to use arrays yet
  12. Blckknight118

    Help with a homework problem

    Ok so I know that Sunday = 0 Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6 I think these numbers are also the offsets and determine which days each month starts at. So for doing it only for January the user would enter in the starting day of Friday. Theres 7 days in the week so you would do 7 - 5 = 2. So the start of the month would look like 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Is this correct?
  13. Blckknight118

    Help with a homework problem

    What I didn't understand is if I am supposed to enter in the day of the week such as 'Tuesday' and the year, but now I know that I have to enter in the year. @Mr Rufelt To write a program that displays the Calender for January using the input of the year, I'm not sure what mathematical equation would be used to solve that. The format is: January 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 I'm not sure how this display would change depending on the year entered. I know 0 = Sunday and 1 = Monday but I don't know how that would change depending on the year entered. @Zero And doesn't the number of days in a month differ each year?
  14. Blckknight118

    Some help on a program

    I finally got it! #include<iostream> using namespace std; int greencrud(int crud_days, int amount_crud); int greencrud(int crud_days, int amount_crud) { int crud_fib = 0; int numberof_crud = amount_crud; int x = crud_days / 5; for( int i = 0; i < x; i++) { int temp = crud_fib + numberof_crud; crud_fib = numberof_crud; numberof_crud = temp; } return numberof_crud; } int main() { char ans; do{ cout << "Welcome to Crud Estimator \n"; cout << "Please enter the number of days the crud has been growing "; int crud_days = 0; cin >> crud_days; cout << "Please enter the original amount of crud "; int amount_crud; cin >> amount_crud; cout << "\nThe number of crud you have in your household is " << greencrud(crud_days, amount_crud) << '\n' << '\n'; cout << "Would you like to enter a different number?"; cout << "\n(Y/N)"; cin >> ans; } while(ans == 'y' || ans == 'Y'); cout << "\nGoodbye!" << endl; return 0; }
  15. Blckknight118

    Some help on a program

    Wow, so I thought I finally had it and started to celebrate a little but the program outputs some right numbers and some wrong. An example would be entering in 5 days and 10 crud and 10 comes out but 15 days and 10 crud is 10 crud. Is there something wrong with my formula? Source: [source lang ="cpp"] #include<iostream> using namespace std; int greencrud(int crud_days, int amount_crud) { int crud_fib = 0; int numberof_crud = amount_crud; int i; int t; for( i = crud_days / 5; i <= crud_days; i++) { t = crud_fib + numberof_crud; crud_fib = numberof_crud; numberof_crud = t; } return numberof_crud; } int main() { int numberofcrud2 = 0; cout << "Welcome to Crud Estimator\n"; cout << "Please enter the number of days the crud has been grown \n"; int crud_days = 0; cin >> crud_days; cout << "Please enter the original amount of crud "; int amount_crud; cin >> amount_crud; cout << "\nThe number of crud you have in your household is " << greencrud(crud_days, amount_crud); return 0; } [Edited by - Blckknight118 on October 19, 2010 3:45:47 PM]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!