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
gulaghasi [49]
3 years ago
6

7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's f

irst two input parameters xVal and yVal into two output parameters xValNew and yValNew. The function returns void. The transformation is new = (old + 1) * 2. Ex: If xVal = 3 and yVal = 4, then xValNew is 8 and yValNew is 10. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #include using namespace std; /* Your solution goes here */ int main() { int xValNew; int yValNew; int xValUser; int yValUser; cin >> xValUser; cin >> yValUser; CoordTransform(xValUser, yValUser, xValNew, yValNew); cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl; return 0; } 1 test passed All tests passed Run Feedback? How was this section?

Computers and Technology
1 answer:
Lilit [14]3 years ago
7 0

Answer:

Here is the CoordTransform() function:              

void CoordTransform(int xVal, int yVal, int &xValNew, int &yValNew){

xValNew = (xVal + 1) * 2;

yValNew = (yVal + 1) * 2; }

The above method has four parameters xVal  and yVal that are used as input parameters and xValNew yValNew as output parameters. This function returns void and transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew according to the formula: new = (old + 1) *

Here new variables are xValNew  and yValNew and old is represented by xVal and yVal.

Here the variables xValNew and yValNew are passed by reference which means any change made to these variables will be reflected in main(). Whereas variables xVal and yVal are passed by value.

Explanation:

Here is the complete program:

#include <iostream>

using namespace std;

void CoordTransform(int xVal, int yVal, int &xValNew, int &yValNew){

xValNew = (xVal + 1) * 2;

yValNew = (yVal + 1) * 2;}

int main()

{ int xValNew;

int yValNew;

int xValUser;

int yValUser;

cin >> xValUser;

cin >> yValUser;

CoordTransform(xValUser, yValUser, xValNew, yValNew);

cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl;

return 0; }

The output is given in the attached screenshot   

You might be interested in
What is the difference between morals and ethics?
Kipish [7]

<u>Answer</u>:

<em>B. Morals are individually held beliefs, while ethics are imposed by an </em>

<em>organization.</em>

<u>Explanation</u>:

<em>Morals are the beliefs designed or created by group of people.</em> It is concerned whether an action is right or wrong. It is basically a lesson learned from a situation or a story. <em>It also convey truth.  </em>

Ethics are set of rules designed by <em>external agent or organization</em> and it differs from place to place but they have basic ethics in common.

<em>It is a branch of philosophy. These are also not relative to the situation. Both moral and ethics are used interchangeably. </em>

6 0
4 years ago
Language: JAVA Can someone please tell me what the problem to my "main" class is?
AleksandrR [38]

Answer:

please find the attachment of the correct code:

Output:

Bob : 1234

sue : 5678

pat : 2468

please enter a name to replace with pat:  

Chris

Bob : 1234

sue : 5678

Chris : 2468

Explanation:

In this code, when we create the class object, that is "stu1, stu2, and stu3" and call the parameterized constructor bypassing the "string and integer" value and print the object value you forget to call the "tostring" method because it is the only method which returns both "string and integer" value.  

6 0
3 years ago
After execution of the code fragment
lesya692 [45]
Yes the output is 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  





8 0
4 years ago
Which of the following code segments will display all of the lines in the file object named infile, assuming that it has success
zimovet [89]

Answer:

d.

for line in infile :

   print(line)

Explanation:

for loop is used to iterate through the each line of the file using line variable. The file is accessed using the object infile. For example if the file name is "file.txt" and it is opened in read mode. It contains the following lines:

hi there friend

how are you

what are you doing

Then the above given chunk of code gives the following output

hi there friend

how are you

what are you doing

At each iteration each line of the the file is printed on the output screen. The print() method is used to display these lines in output.

5 0
3 years ago
What is cloud based LinkedIn Automation?
Zielflug [23.3K]

Answer:

The cloud-based LinkedIn automation tool makes life easier for you by automating functions like sending connection requests, liking and commenting on posts, sending customized messages, and much more.

6 0
3 years ago
Read 2 more answers
Other questions:
  • You should type------ space(s) after a period at the end of a sentence.
    13·2 answers
  • Which Command Prompt commands in Windows is used for listing a computer connections to shared resources
    10·1 answer
  • The network ____, the person overseeing network operations, uses a server operating system to add and remove users, computers, a
    15·1 answer
  • Privacy concerns, financial information, security of your personal data has
    14·1 answer
  • Which term describes the order of arrangement of files and folders on a computer?
    10·1 answer
  • The use of _______________ can validate input responses from clients and prevent certain attack methodologies
    14·1 answer
  • To delete a row, you must first
    11·1 answer
  • Why is it important to ensure that your software is up to date?
    13·1 answer
  • Define a class Person that represents a person. People have a name, an age, and a phone number. Since people always have a name
    7·2 answers
  • A class researching the world’s population would like to include a graph that shows historical changes. They have information fr
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!