Hello i am trying to complete an assignment and am having a bit of trouble. 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. I can't help but feel I'm not because I've searched and searched through our notes and slides only to come up empty handed. Heres the code if it helps, and thank you again.
// 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;
Howabout this one. Everything is working until i put something other than a vowel in. No matter what the letter it is saying they are all consonants or whatever the last else is.
// File: Lesson09P1.cpp
// Created by Chris Sykes on 2/27/14
// This program displays letters in uppercase and whether or not they are a vowel.
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
// Declare variables
char letter = ' ';
// Request input
cout << "Enter letter: ";
cin >> letter;
letter = toupper(letter);
// Determine whether letter is a vowel
if (letter == 'a' || 'e' || 'i' || 'o' || 'u')
{
cout << "Vowel " << letter << endl;
}
else
{
cout << "Consonant " << letter << endl;
}
system("pause");
return 0;
}
1) It should actually tell you that everything is a vowel.
2) You are using toupper function and then comparing it to lovercase letter.
3) Tell me what 'e' || 'i' || 'o' || 'u' should equal to in your code (Hint, it is always TRUE)
Your compiler should warn you that this line does not do anything useful. If your compiler does not do that, either turn on warnings or change it to something more useful.
You cannot use logic operators like that. You have to write if (letter == 'a' || letter == 'e' ||...) or use some other way to detect vowels.
1) ya your right
2) why would it matter if i use the topper function and then use lowercase? won't it automatically change every lowercase letter to a capital one?
3) i had already tried what you said to no avail
here it is with the changes you suggested, what am i still doing something wrong?
// File: Lesson09P1.cpp
// Created by Chris Sykes on 2/27/14
// This program displays letters in uppercase and whether or not they are a vowel.
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
// Declare variables
char letter = ' ';
// Request input
cout << "Enter letter: ";
cin >> letter;
letter = toupper(letter);
// Determine whether letter is a vowel
if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter 'U')
{
cout << "Vowel " << letter << endl;
}
else
{
cout << "Consonant " << letter << endl;
}
system("pause");
return 0;
}
why would it matter if i use the topper function and then use lowercase? won't it automatically change every lowercase letter to a capital one?
It would change case of letter you entered to upper. It is like replacing one value with another. After that you comparing your new value to other letter.