# Blckknight118

Member

67

124 Neutral

• Rank
Member
1. ## 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. ## 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. ## 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. ## 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. ## 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. ## 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

8. ## 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. ## 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} ??

11. ## 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. ## 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. ## 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. ## 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. ## 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]