Question

part 1(do not write on note book and before send program compile it) void testStruct01() this...

part 1(do not write on note book and before send program compile it) void testStruct01()

this function is called from main

in main()

call the function void test01()

in the function void test01()

1. create a FootballTeam object   
2. using 'cin', load the FootballTeam object  
3. using 'cout', display (print) the FootballTeam object
4. output should look like the following

        ********** AFC East **********

Home Team              XXXXXXXXXXXXXXXXXXXXXXXX

Opponent team          XXXXXXXXXXXXXXXXXXXXXXXX

Home Team score        XXXXXXXXXXXXXXXXXXXXXXXX

Opponent team score   XXXXXXXXXXXXXXXXXXXXXXXX

part 2 (do not write on note book and before send program compile it)  

Purpose of this program. Pass a struct to a function

  1. Start with your Struct01 code.
  2. Copy and rename your Struct01 code Struct01A.
  3. Change program name, date due, and add to remarks in the program heading

Leave the testing function testStruct01() in the program. Comment out the function call in int main()

  1. copy testStruct01() and rename that function as testStruct01A()
  2. add a new function named void testStruct01B(FootballTeam fb) to your program.
  3. This new function will receive a FootballTeam struct as a parameter.

This is how you will set up the test…………

  1. In void testStruct01A(), create and print your FootballTeam struct. (that code should already be there.)
  2. Pass the FootballTeam object to the new function

               void testStruct01B(FootballTeam fb).

  1. Print the passed FootballTeam object in this new function.
  2. If everything prints out OK, the structor has been passed correctly

You will see that most of the code is cut-and-paste from your Struct01 program

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

Answer;

part1:

#include <iostream> // needed for Cin and Cout

#include <string> // needed to manipulate strings

#include <iomanip> // needed for output formatting

using namespace std;

/*********************************

* struct definition

**********************************/

struct FootballTeam

{

string team; // team name

string opponent; // opponent name

int teamScore; // teams score

int oppoScore; // opponents score

};

/*********************************

* prototypes here

**********************************/

void testStruct01();

/***************************************

* there are no global variables

***************************************/

int main()

{

testStruct01();

system("pause");

return 0;

}

void testStruct01()

{

cout << "**********************************\n";

cout << "* in void test01() *\n";

cout << "**********************************\n\n\n";

FootballTeam team; // create a FootballTeam object

// loading the FootballTeam object

cout<<"Enter team name \n";
cin>>team.team;
cout<<"Enter opponent team name \n";
cin>>team.opponent;
cout<<"Enter team score \n";
cin>>team.teamScore;
cout<<"Enter opponent team score \n";
cin>>team.oppoScore;
cout<<"\n";
// print the FootballTeam object

cout<<"Home Team :"<<setw(29)<<right<<team.team<<endl;
cout<<"Opponent Team :"<<setw(25)<<right<<team.opponent<<endl;
cout<<"Home Team score :"<<setw(23)<<right<<team.teamScore<<endl;
cout<<"Opponent Team score :"<<setw(19)<<right<<team.oppoScore<<endl;

}

Add a comment
Know the answer?
Add Answer to:
part 1(do not write on note book and before send program compile it) void testStruct01() this...
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
  • C++ #include            // needed for Cin and Cout #include            //...

    C++ #include            // needed for Cin and Cout #include            // needed to manipulate strings #include            // needed for output formatting using namespace std; /********************************* * struct definition **********************************/ struct FootballTeam { string team; // team name string opponent; // opponent name int teamScore; // teams score int oppoScore; // opponents score }; /********************************* * prototypes here **********************************/ void testStruct01A(); /*************************************** * there are no global variables ***************************************/ int main() { testStruct01A();...

  • C++ codes ( please use Dev++ compiler ) please send the full program and please compile...

    C++ codes ( please use Dev++ compiler ) please send the full program and please compile before send linked list program with the delete function (and traverse) void delNode(node** start, int delNum) if there is no match, print an error message otherwise, delete node do not forget the test plan and code

  • Lab 3 Step One First, create an empty directory for lab3. There is no starter code for this lab. You will be throwing an...

    Lab 3 Step One First, create an empty directory for lab3. There is no starter code for this lab. You will be throwing and catching exceptions in this exercise. Create a file called RuntimeException.h and put the following code in it. #include <string> class RuntimeException { private: string errorMsg; public: RuntimeException(const string& err) { errorMsg = err; } string getMessage() const { return errorMsg; } } Step Two In a new .cpp file in your directory, write a main function...

  • Lab 3 Step One First, create an empty directory for lab3. There is no starter code...

    Lab 3 Step One First, create an empty directory for lab3. There is no starter code for this lab. You will be throwing and catching exceptions in this exercise. Create a file called RuntimeException.h and put the following code in it. #include <string> class RuntimeException { private: string errorMsg; public: RuntimeException(const string& err) { errorMsg = err; } string getMessage() const { return errorMsg; } } Step Two In a new .cpp file in your directory, write a main function...

  • Write a program that will do the following. The main function should ask the user how...

    Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...

  • **Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of...

    **Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of your own design. The class should contain a protected int member variable var, which is initialized with an integer value between 1 and 50 in a constructor that takes an integer parameter. The class should contain a public member function called playthat should print out a sequence of integers as a result of iteratively applying a math function f to the member variable var...

  • MUST BE WRITTEN IN C++ All user input values will be entered by the user from...

    MUST BE WRITTEN IN C++ All user input values will be entered by the user from prompts in the main program. YOU MAY NOT USE GLOBAL VARIABLES in place of sending and returning data to and from the functions. Create a main program to call these 3 functions (5) first function will be a void function it will called from main and will display your name and the assignment, declare constants and use them inside the function; no variables will...

  • ***Program must compile under Ubuntu! (35 pts) Write a C++ program A4p3.cpp with a class that...

    ***Program must compile under Ubuntu! (35 pts) Write a C++ program A4p3.cpp with a class that is a derived class of your class from problem 2. Add a private intmember variable var2 to this class. Initialize the member variables var and var2 with values between 1 and 50 using a constructor that takes two integer parameters. Add a public member function called getsp that should print out the sum and product of var and var2. In your main function, create...

  • This part requires you to write two programs, compile them, and execute them - just like...

    This part requires you to write two programs, compile them, and execute them - just like our lab questions.  You may access these questions as many times as you need to and you have the entire duration of the test to complete these problems. You must submit the program code and the sample outputs for each problem - just like lab. These questions are worth 6 points each. 1.      C++ Write a program that reads 20 data values from a data...

  • USING C++ PROGRAM Instructions - Part C Write a program that has three functions: All characters...

    USING C++ PROGRAM Instructions - Part C Write a program that has three functions: All characters printed should be in White ► Call the first function from main().Print "I'm in main" (as shown in example) > Print "I'm in function 1" in the first function. Call the second function. ► Print "I'm in function 2” in the second function and then ask the user to enter a float value. Enter 25 Call a third function and pass the value to...

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