I know what i want to do, i just don't know how to tell my computer to do it.

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;

int main()
{
// Declare variables
double totIncome = 0.0;
double totChild = 0.0;
double taxCredit = 0.0;

// Request input
cout << "Total income:";
cin >> totIncome;
cout << "Amount of children:";
cin >> totChild;

// Check about graduation and display message
if (totIncome < 70000)
{
taxCredit = totChild * 1000;
cout << taxCredit << endl;
}
else
// This is where I'm having the trouble
{
taxCredit = totChild * 1000;
cout << taxCredit << endl;
}

system("pause");
return 0;
}
Change line taxCredit = totChild * 1000; to taxCredit = std::min(totChild * 1000, 4500);
tried that but I'm getting the following error: No matching function for call to 'min'

what would i have to do to add the 'min' function into the code?

Thanks again for the help
#include <algorithm>
when putting code here do this...

"["code"]" paste your code here "["/code"]"

without all the quotations obviously

that way your code can be read easily

Last edited on
thanks noob i was wondering how to do that. and i also figured it out with the help of this board. thanks guys
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.

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
32
33
34
35
36
 

// 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>
using namespace 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?

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
32
33
// 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>
using namespace 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;
}
Last edited on
You forgot == in letter 'U'

It should work after that.

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.
Topic archived. No new replies allowed.