🔒 Closed C++ code help

  • Thread starter Thread starter Deleted member 1079204
  • Start date Start date
Status
Not open for further replies.
D

Deleted member 1079204

pa help po sa paggawa ng code di po gumagana yung code na nagawa ko po e wrong computation

Screenshot_2021-11-27-18-51-25-41.webp

ito po yung ginawa ko may mali sa computation di ko pa po ginawa yung married na part kasi mali na yung single e
Screenshot_2021-11-29-16-32-00-22_a927ed2714ba3b9021f681846134c26f.webp

Screenshot_2021-11-29-16-33-10-09_a927ed2714ba3b9021f681846134c26f.webp

it should be 3,350
 
Dapat && ang gamitin mo sa pacheck ng income, hindi ||. At isama mo na rin ang equal sign.

C++:
if (income > 0 && income <= 8000)
ampersand po ba gagamitin pag data range?
 
Code:
#include <iostream>
using namespace std;

int main(){
    double income=0.0;
    double taxP1 = 0.10, taxAdd1 = 0.0, taxOver1=0.0;
    double taxP2 = 0.15, taxAdd2 = 800.0, taxOver2=8000.0;
    double taxP3 = 0.25, taxAdd3 = 4400.0, taxOver3=32000.0;

    double taxAdd1M = 0.0, taxOver1M=0.0;
    double taxAdd2M = 6000.0, taxOver2M=16000.0;
    double taxAdd3M = 8800.0, taxOver3M=64000.0;

    double TotalTax = 0.0;
    char status = ' ';

    cout<<"Welcome to TAX Computation Program"<<endl;
    cout<<"Please choose: [S] - Single [M] - Married"<<endl;
    cout<<"Please enter your status: ";
    cin>>status;
    cout<<endl;
    switch(status) {
        case 'S': case 's':
            cout<<"Enter amount (Income): ";
            cin>>income;
            if(income>=0 && income<8000){
                TotalTax = (income - taxOver1) * taxP1 + taxAdd1;
            }
            else if(income>=8000 && income<32000){
                TotalTax = (income - taxOver2) * taxP2 + taxAdd2;
            }
            else if(income>=32000){
                TotalTax = (income - taxOver3) * taxP3 + taxAdd3;
            }
            else{
                cout<<"No negative income";
            }

            cout<<"Total Tax Amount Due: "<<TotalTax<<endl;
            break;

        case 'M': case 'm':
            cout<<"Enter amount (Income): ";
            cin>>income;
            if(income>=0 && income<16000){
                TotalTax = (income - taxOver1M) * taxP1 + taxAdd1M;
            }
            else if(income>=16000 && income<64000){
                TotalTax = (income - taxOver2M) * taxP2 + taxAdd2M;
            }
            else if(income>=64000){
                TotalTax = (income - taxOver3M) * taxP3 + taxAdd3M;
            }
            else{
                cout<<"No negative income";
            }

            cout<<"Total Tax Amount Due: "<<TotalTax;
            break;

        default:
            cout<<"[S] or [M] only"<<endl;
    }
    cout<<endl;
    return 0;
}
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 6
    Replies
  • 452
    Views
  • 3
    Participants
Last reply from:
Unknown user

Online now

Members online
1,047
Guests online
690
Total visitors
1,737

Forum statistics

Threads
2,276,966
Posts
28,973,387
Members
1,229,669
Latest member
zeeeee345
Back
Top