Re: How to do this in QT?
Code:
void MainWindow::on_pushButton_clicked(){
int x,salary;
x=ui->lineEdit->text().toInt(0);
if(x<=5000){
salary=x;
}
else if(x>=7000){
salary=x-5000;
salary=(salary*5)/100;
salary=x-salary;
}
else if(x>=10000){
salary=x-(x*10/100);
}
else if(x<10000 && x<20000){
salary=x-10000;
salary=salary*10/100;
salary=salary+250;
salary=x-salary;
}
}
This is what i understood from your example. If you want any further help then you're welcome.
Re: How to do this in QT?
I'd be more inclined to handling this (homework?) question the other way around:
Code:
float salary = 11000.0;
float tax = 0.0; // I wish ;)
if (salary > 10000.0)
tax = 0.10 * (salary - 10000.0) + 250.0; // 250 is the tax on the first 10000
else if (salary > 5000.0)
tax = 0.05 * (salary - 5000.0); // + 0.0; 0.0 is the tax on the first 5000
else
tax = 0.0;
In a real-world situation you will have all sorts of rounding rules to take into consideration.
Re: How to do this in QT?
Quote:
Originally Posted by
sonulohani
Code:
void MainWindow::on_pushButton_clicked(){
int x,salary;
x=ui->lineEdit->text().toInt(0);
if(x<=5000){
salary=x;
}
else if(x>=7000){
salary=x-5000;
salary=(salary*5)/100;
salary=x-salary;
}
else if(x>=10000){
salary=x-(x*10/100);
}
else if(x<10000 && x<20000){
salary=x-10000;
salary=salary*10/100;
salary=salary+250;
salary=x-salary;
}
}
This is what i understood from your example. If you want any further help then you're welcome.
Thank you so much for your help . I finished the application and its working perfectly.
Code:
void MainWindow::on_pushButton_clicked()
{
int x,salary ;
x=ui->lineEdit->text().toLong(0);
if (x<=5000)
{
salary=x ;
}
else if (x>5000 && x<=10000)
{
salary=x-5000;
salary=(salary*5)/100 ;
salary=x-salary ;
}
else if (x>10000){
salary=x-10000;
salary= (salary*10)/100 ;
salary=salary+250 ;
salary=x-salary;
}
}