Explanation of Solution
The program execution is explained in the in-lined comments:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare pointer variables and allocate memory
double *trip1Cost = new double;
double *trip2Cost = new double;
double *trip3Cost = new double;
double *max;
//store values in the allocated memory
*trip1Cost = 100.00;
*trip2Cost = 350.00;
//assign pointer variables to each other
//trip3Cost now points to location having
//stored 350.00 later trip2Cost points
//to location having a stored value 100.00
trip3Cost = trip2Cost;
trip2Cost = trip1Cost;
//trip1Cost is now pointed to freshly allocated
//memory location and assigned value
trip1Cost = new double;
//trip1Cost points to a location having
//stored value of 175 and trip3Cost now
//points to a location having a stored value 275
*trip1Cost = 175;
*trip3Cost = 275;
//sets the output format
cout << fixed << showpoint << setprecision(2);
//prints the arithmetic expression
//(*trip1Cost + *trip2Cost + *trip3Cost) which
//evaluates to (175 + 100...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
C++ Programming: From Problem Analysis to Program Design
- C++ Please How do I compare four numbers and rank them from highest to lowest. For example, I ask a user to enter a grade for four students and I want them to show the student from highest to lowest and the display the person with the highest grade as well.arrow_forwardCan you help with this?arrow_forwardCODE USING C++ Can you identify if Cody's name is spelled right? If so, then make a program that accepts four one-letter strings separated by space and print "Correct" if the inputted strings, combined in order, spell the name Cody correctly. If not, print "Wrong". It doesn't matter if it's in uppercase or lowercase, as long as it's spelled correctly, it's considered correct. Now, will you take on this task? Input A line containing four one-letter strings separated by a space. c·O·D·y Output A line containing a string. Correctarrow_forward
- Code in C++ please, with comments to guide the code.arrow_forwardwrite code in c++ pleasearrow_forwardplease solve the question new solution, don't copy other solutions in questions bank c++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0).…arrow_forward
- Write a program in C++ code:arrow_forwardQuestion 5 Write a program in C++ that ranks a data set of Poker hands.2 3 4 5 6 7 8 9 10 J Q K A Suit: S H D C**This program should be able to tell the difference between higher hands of flushes and rank them accordingly. Full explain this question and text typing work only thanksarrow_forwardc++, find th outputarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education