Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#15 The swap function from Lab B was coded as: void swap (int& a, int& b) {int hold; hold = a; a = b; b

#15 image text in transcribed
The swap function from Lab B was coded as: void swap (int& a, int& b) {int hold; hold = a; a = b; b = hold;} Which of the following calls to swap in main are valid? (Remember Question 8) a.) int x = 1, y = 3; swap(x, y) b.) swap (10, 5); c.) int x = 1, y = 3; swap(x, y + 5); d.) double x = 1.5, y = 3.2 swap (x, y); Code a main program and the functions to do the following: A function to Read in double variables of length and width, using the keyboard A function to Calculate and return a double of the area of a rectangle A function to Print the length and width of the lot, the length and width house, area be cut, and time to cut in minutes The application (main method) wants to know how much time to cut the grass of a rectangle lot with a rectangle house sitting in the middle of the lot. There are multiple sets of data, the last one has -1 -1 for the length and width. The algorithm is: 1, set varibles of lengthHouse, widthHouse, lengthYard, widthYard, areaLot, areaHouse, areaToCut, timeToCut 2 Set a constant of 2 seconds, called time, which is the time to cut 1 square foot of grass 3 call Read function to read lenth and with of yard 4 while (lengthYard ! = -1) 4.1 call Read function to read and width of house 4.2 call Calculate function to calculate area of yard, returning areaLot 4.3 call Calculate function to calculate area of house, returning value to area House 4.4 areaToCut = area Lot - areaHouse 4.5 timeToCut = areaToCut/time/60 4.7 call Print function 4.8 call Read function to read length and width of yard 5. Stop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions