Ok so I'm taking my first programming class (intro to prig and logic) and have pretty limited computer knowledge. Im loving the class right now and have been pretty good at picking up on how this whole thing works. However, I have labs for units 5-10 due this week and for some reason there is one problem on unit 5 i just can't seem to figure out. I cruised through the later materials, but for some reason this one is just giving it to me. I don't know if its something obvious or not (i am just a beginner), but i just can't seem to get my totals to come up correctly. I did some googling but everything i found was at a much higher level than what I'm doing. I tried doing each total individually to see what happened and if i just do one it comes out correctly. If i had a second total to be added to the first, its like its just giving me the second total by itself and when i add the third it just adds the second and third totals. Its frustrating the heck out of me because I'm getting most of the harder tasks. Anyways please help me anyway you can, and try and be easy on me, I'm just learning. Thank you.
fire thank you so much. i knew it was going to be something simple like that (face palm). I swear i looked this thing over again and again. Guess my professor was right when she said the best way to find simple mistakes is just have someone take a quick look over your code. Thanks again.
May I ask why you have the number of people as doubles? Do you consider something missing a limb to be part of a person? Also your prices are all integers 90, 110, 160 so you could make everything an integer for a little bit more precision.
Still new to this, so even your question is a bit puzzling to me. I have the people as doubles because thats how i remember doing it in class. Is it unnecessary or should i be doing something else instead? Im not to sure what the missing limb question means, I'm guessing it pertains to using people as doubles? And as far as the last part what other number were you saying to make an integer? Please feel free to get back to me i really appreciate the help and knowledge. Thank you
Basically you want to use double when you have decimal values eg (1.27) and integer when they are integer values eg (5). Doubles are not as precise as integers so you could be off by a little bit (prob won't affect this program) because of the way that they are stored.
Since the price are integers 90 , 110 , 160 you will always have a total price that is an integer also so there will be no change like $1.50 or something so you would be best writing it as all integers:
1 2 3 4 5 6 7
int numRegMorning = 0;
int numRegAfternoon = 0;
int numRegWholeDay = 0;
int totFeeMorning = 0;
int totFeeAfternoon = 0;
int totFeeWholeDay = 0;
int totFee = 0;
Hey blit, if your still on, heres another one I'm having a problem with a little farther down. I have to write a program that ill show how much of a child tax credit certain households will receive. If income is under 70000 they receive 1000 per child. If the income is above 70000 they cannot claim more than 4500 regardless of amount of kids. I have everything else coded and done but i don't know how to limit the tax credit for those over 70000. How do i say 1000 per child up to 4500. Im a little frustrated because i don't know if I'm just missing something i should already know. Im pretty sure theres not anything else wrong, just don't know how to make that command happen. Ive looked through our notes, handouts, and slides pertaining to this lesson and still nothing. Maybe I'm over thinking it and theres more logical way to calculate this. Again any help is much appreciated.
// File: Lesson08P1.cpp
// Created by Chris Sykes on 2-27-14
// This program ucalculates and displays the total child tax credit households can clam based on income.
#include <cstdlib>
#include <iostream>
using namespace std;
Yes you can mix and match variable types.
Though keep in mind double you should assign a decimal after the integer (0 = 0.0)value. It will implicitly cast it if you forget though.
You could do a few different things.
You could
1) multiply the children by 1000 and check if that is greater than 4500 and if so assign it a value of 4500 or
2) check if there are 5 or more children if so assign 4500 to be the credit.
3) if children less than 5 value is 4500 else 100 * children
else
// This is where I'm having the trouble *************************
{
taxCredit = totChild * 1000;
cout << taxCredit << endl;
}
//replaced with:
elseif(totChild < 5) //4 or less children it will have already checked
//less than 70000 and failed
//so that would implicitly mean it has 70000 or more
//so you don't need to check that again
{
taxCredit = totChild * 1000.0; //.0 casts to integer
//int * int = int
//float/double * int = float/double
}
else //more than 70000 and more than 4 children
{
taxCredit = 4500.0;
}
Thanks a million Blit. This definitely helped me out big time. Im sure the more i stay with it the simpler it will come to me. If you don't mind me asking, whats your profession? Well i guess i don't mean whats your profession, im just a bit curious about how you know all this. I just stumbled upon this class but I'm really enjoying it and want to learn more and more about it. Again bud thanks for everything, I'm sure ill have more questions.