1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aleksklad [387]
3 years ago
13

IN C++, write a program may execute the same computations repeatedly.The program below repeatedly asks the user to enter an annu

al salary, stopping when the user enters 0 or less. For each annual salary, the program determines the tax rate and computes the tax to pay.
1. Run the program below with annual salaries of 40000, 90000, and then 0.
2. Modify the program to use a while loop inside the given while loop. The new inner loop should repeatedly ask the user to enter a salary deduction, stopping when the user enters a 0 or less. The deductions are summed and then subtracted from the annual income, giving an adjusted gross income. The tax rate is then calculated from the adjusted gross income.
3. Run the program with the following input: 40000, 7000, 2000, 0, and 0. Note that the 7000 and 2000 are deductions.

Computers and Technology
1 answer:
Fofino [41]3 years ago
6 0

Answer:

Check the explanation

Explanation:

c++ Program to find Gross salary after deducting tax from the annual salary

In this program user have to enter the annual salary,tax rate.This program continue to run repeatedly untill user gives 0 for annual salary.

#include <iostream>

using namespace std;

int main()

  {

      double asal,taxPay,trate;

      char c;

      while(true)

      {

  cout <<"Enter The Annual Salary ::";

      cin>> asal;

          if(asal<=0)

      {

          cout<<"* Program Exit *";

          break;

      }

      cout<<"\nEnter Tax Rate::";

      cin>>trate;

 

      taxPay=asal*(trate/100);

      cout<<"\nTax You Have to pay::"<<taxPay<<endl;

 

        }

}

_____________________

Kindly check the first attached image below for the code output.

2) Modified the above program

#include <iostream>

using namespace std;

int main()

  {

      double asal,taxPay,trate,deduction;

      char c;

      while(true)

      {

  cout <<"\nEnter The Annual Salary ::";

      cin>> asal;

          if(asal<=0)

      {

          cout<<"* Program Exit *";

          break;

      }

      while(true)

      {

          cout<<"Enter Salary Deductions::";

          cin>>deduction;

          if(deduction<=0)

          {

          break;

          }else

          {

              asal=asal-deduction;

          }

         

      }

      cout<<"\nEnter Tax Rate::";

      cin>>trate;

 

      taxPay=asal*(trate/100);

      cout<<"\nTax You Have to pay::"<<taxPay<<endl;

      cout<<"Salary remaining after all deductions::"<<asal;

      }

  return 0;  

  }

Kindly check the second attached image below for the code output.

You might be interested in
Explain why you should research a potential employer before actively seeking employment
Leona [35]
He/she could have a bad history or be a killer. :p
3 0
4 years ago
Which of the following is a function of the slip yoke used on a driveshaft?
Harrizon [31]
It has to be all of the above because A and B are both true.

<span>It allows movement between the suspension as it reacts to the road surface, which also allows the driveshaft to change length to configure to the road.</span>

7 0
4 years ago
A or an is a simple chip with two or more processor core
Sergio039 [100]
A multi-core processor, i’m pretty sure
5 0
4 years ago
Show the dynamic and speculation execution for the following code
djyliett [7]

Answerf9,f10,fll

Explanation:

6 0
3 years ago
Write a program that reads the lengths of the sides of a triangle from the user. Compute the area of the triangle using Heron's
slamgirl [31]

Answer:

The java program is as follows.

import java.util.Scanner;

import java.lang.*;

public class Area

{

   //variables to hold the values

   static double a, b, c;

   static double s;

   static double area;

public static void main(String[] args) {

    //scanner class object created

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the first side: ");

 a=sc.nextInt();

 System.out.print("Enter the second side: ");

 b=sc.nextInt();

 System.out.print("Enter the third side: ");

 c=sc.nextInt();

 s=(a+b+c)/2;

 //function of Math class used

 area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

 //result displayed with 3 decimal places

 System.out.printf("The area of the triangle is %.3f", area);  

}

}

OUTPUT

Enter the first side: 1

Enter the second side: 1

Enter the third side: 1

The area of the triangle is 0.433

Explanation:

1. The variables to declare the three sides of the triangle, the semi-perimeter and the area of the triangle are declared with double datatype. All the variables are declared at class level and hence, declared with keyword, static.  

2. Inside main(), an object of the Scanner class is created.

Scanner sc = new Scanner(System.in);

3. Using the Scanner class object, user input is taken for all the three sides of the triangle.

4. Following this, the semi-perimeter is computed as shown.

s=(a+b+c)/2;

5. The area of the triangle is computed using the given formula which is implemented as shown.

area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

6. The sqrt() method of the Math class is used while computing the area of the triangle.

7. The area is displayed with three decimals. This is done using the printf() method as shown.

System.out.printf("The area of the triangle is %.3f", area);

8. The program is saved with the same name as the name of the class having the main() method.

9. The class having the main() method is always public.

3 0
3 years ago
Other questions:
  • How to the inverse function of f(x)=x2 +1 ,x&gt;o
    5·1 answer
  • How do you adjust the shear of a shape?
    10·2 answers
  • If the boolean expression a is true and b is false, the value of the logical expression a or b is ________.
    14·1 answer
  • Which building-block feature is available in the Text grouping on the Insert tab?
    14·1 answer
  • Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The
    8·1 answer
  • Why do we allow electronic instruments to warm-up before use?
    11·1 answer
  • A security manager has discovered that sensitive information stored on a server has been compromised. The organization is requir
    7·1 answer
  • Wi-fi works by converting data signals into which of the following?
    8·2 answers
  • A ________ is a single media file including art, sound, animation, or movies.
    9·1 answer
  • SOMEONE PLEASE HELP!! i’ll give brainliest
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!