Question

Create a C++ project called lab3b and add the following source code init_struct.cpp to the project....

Create a C++ project called lab3b and add the following source code init_struct.cpp to the project.

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

// This program demonstrates partially initialized structure variables

// PLACE YOUR NAME HERE

struct taxPayer

{

       string name;

       long socialSecNum;

       float taxRate; float income; float taxes;

};

int main()

{

       // Fill in code to initialize a structure variable named citizen1 so that

       // the first three members are initialized. Assume the name is Tim

       // McGuiness, the social security number is 255871234, and the tax rate is .35

       // Fill in code to initialize a structure variable named citizen2 so that

       // the first three members are initialized. Assume the name is John Kane,

       // the social security number is 278990582, and the tax rate is .29

       cout << fixed << showpoint << setprecision(2);

       // calculate taxes due for citizen1

       // Fill in code to prompt the user to enter this year's income for the citizen1

       // Fill in code to read in this income to the appropriate structure member

       // Fill in code to determine this year's taxes for citizen1

       cout << "Name: " << citizen1.name << endl;

       cout << "Social Security Number: " << citizen1.socialSecNum << endl;

       cout << "Taxes due for this year: $" << citizen1.taxes << endl << endl;

       // calculate taxes due for citizen2

       // Fill in code to prompt the user to enter this year's income for citizen2

       // Fill in code to read in this income to the appropriate structure member

       // Fill in code to determine this year's taxes for citizen2

       cout << "Name: " << citizen2.name << endl;

       cout << "Social Security Number: " << citizen2.socialSecNum << endl;

       cout << "Taxes due for this year: $" << citizen2.taxes << endl << endl;

       return 0;

}

Exercise 1: Fill in the code as indicated by the comments in bold.

(Paste your updated code and screen shot here)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

// This program demonstrates partially initialized structure variables

// PLACE YOUR NAME HERE

struct taxPayer

{

       string name;

       long socialSecNum;

       float taxRate; float income; float taxes;

};

int main()

{

       // Fill in code to initialize a structure variable named citizen1 so that

       // the first three members are initialized. Assume the name is Tim

       // McGuiness, the social security number is 255871234, and the tax rate is .35

       // Fill in code to initialize a structure variable named citizen2 so that

       // the first three members are initialized. Assume the name is John Kane,

       // the social security number is 278990582, and the tax rate is .29


       taxPayer citizen1,citizen2;

       citizen1.name="Tim McGuiness";
       citizen1.socialSecNum=255871234;
       citizen1.taxRate=0.35;

       citizen2.name="John Kane";
       citizen2.socialSecNum=278990582;
       citizen2.taxRate=0.29;


       cout << fixed << showpoint << setprecision(2);

       // calculate taxes due for citizen1

       // Fill in code to prompt the user to enter this year's income for the citizen1

      // Fill in code to read in this income to the appropriate structure member

       // Fill in code to determine this year's taxes for citizen1

       cout<<"Enter this year's income for citizen 1: ";
       cin>>citizen1.income;

       citizen1.taxes=citizen1.taxRate*citizen1.income;

       cout << "Name: " << citizen1.name << endl;

       cout << "Social Security Number: " << citizen1.socialSecNum << endl;

       cout << "Taxes due for this year: $" << citizen1.taxes << endl << endl;

       // calculate taxes due for citizen2

       // Fill in code to prompt the user to enter this year's income for citizen2

       // Fill in code to read in this income to the appropriate structure member

       // Fill in code to determine this year's taxes for citizen2

       cout<<"Enter this year's income for citizen 2: ";
       cin>>citizen2.income;

       citizen2.taxes=citizen2.taxRate*citizen2.income;


       cout << "Name: " << citizen2.name << endl;

       cout << "Social Security Number: " << citizen2.socialSecNum << endl;

       cout << "Taxes due for this year: $" << citizen2.taxes << endl << endl;

       return 0;

}


Output:

Add a comment
Know the answer?
Add Answer to:
Create a C++ project called lab3b and add the following source code init_struct.cpp to the project....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Part 1 Fill in the code below as indicated by the comments in bold // PLACE...

    Part 1 Fill in the code below as indicated by the comments in bold // PLACE YOUR NAME HERE // This program demonstrates how to use an array of structures #include <iostream> #include <iomanip> using namespace std; // Fill in code to declare a structure called taxpayer that has three // members: taxRate, income, and taxes – each of type float // ??? int main() { // Fill in code to define an array named citizen which holds 1/ 5...

  • I Need Help. I MUST USED VECTOR OF STRUCTUERS INSTEAD OF AN ARRAY. HOW CAN MAKE...

    I Need Help. I MUST USED VECTOR OF STRUCTUERS INSTEAD OF AN ARRAY. HOW CAN MAKE THIS INTO VECTOR STRUCTUERS? #include #include using namespace std; // This program demonstrates how to use an array of structures// PLACE YOUR NAME HERE // Fill in code to define a structure called taxPayer that has three// members: taxRate, income, and taxes -- each of type float int main(){   // Fill in code to declare an array named citizen which holds   // 5 taxPayers structures cout...

  • I need to get this two last parts of my project done by tonight. If you...

    I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...

  • Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All...

    Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All rights reserved. // #include<iostream> #include<fstream> #include<cstdlib> #include<regex> #include <iomanip> using namespace std; float grossPay(float hrsWorked, float payrate); float grossPay(float hrsWorked, float payrate){ return hrsWorked*payrate;       } int main(){    //opening an output file ifstream outFile("Employee.txt", ios::in); //Read variables string depId,emp_num,firstName,lastName,email,hrs_worked,pay_rate,ch="y";    //Regex patterns regex integerPattern("(\\+|-)?[[:digit:]]+"); regex...

  • Ship, CruiseShip, and CargoShip Classes (in C++ language i use visual studios to code with) design...

    Ship, CruiseShip, and CargoShip Classes (in C++ language i use visual studios to code with) design a Ship class that has the following members: - A member variable for the name of the ship (a string) - A member variable for the year that the ship was built (a string) - A contsructor and appropriate accessors and mutators - A virtual print function that displays the ship's name and the year it was built (nobody seems to get this part...

  • C++ Program: Given the following C++ code, complete it so that it keeps track of the...

    C++ Program: Given the following C++ code, complete it so that it keeps track of the Detroit Tigers record and winning percentage. The prompt asks the user for one of four options. Here are the options and what they do: ● “w” for win – this adds one to the number of wins and shows the record in a wins-losses format (for example, 4-3). ● “l” for loss – this adds one to the number of losses and shows the...

  • C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose...

    C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose we have the job to make a program that accepts a dinner reservation. The information collected will be the name of the customer, the date for the reservation, the time for the reservation (good choice for a hierarchical struct), the number in the party, email address (for updates) and phone number. Define a hierarchical structure for a dinner reservation that will contain the above...

  • Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int...

    Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int main0 // define two integers int x-3; int y = 4; //print out a message telling which is bigger if (x >y) i cout << "x is bigger than y" << endl: else cout << "x is smaller than y" << endl; return 0; Example (5) Write a C++ program that takes from the user a number in SR (Saudi Riyal) then the program...

  • in C++ creat a DynamicQueue class, add a new data member called count to trace the...

    in C++ creat a DynamicQueue class, add a new data member called count to trace the total number of node you have in current queue (you need to modify some member functions for adding count). Add a member function called displayQueue() to display values stored in each node in the current queue, also the total number of nodes in the queue. You also need to have a driver program (refer to Tester) to test your modified new class and new...

  • C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to...

    C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to the project. Copy and paste the code is listed below: Design a class named Employee. The class should keep the following information in member variables: Employee name Employee number Hire date // Specification file for the Employee class #ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { private:        // Declare the Employee name string variable here. // Declare the Employee...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT