Question: Can someone do these for me Exercise 2-2. The point of this exercise is (1) to use string concatenation to display values with different types

Can someone do these for me

Exercise 2-2.

The point of this exercise is (1) to use string concatenation to display values with different types (int and string), and (2) to practice developing programs gradually by adding a few statements at a time.

Create a new program named date.cpp. Copy or type in something like the hello world program and make sure you can compile it and run it.

Following the example in "Outputting Variables" on page xx, write a program that creates variables named day, date, month, and year. The variable day will contain the day of the week (like Friday), and date will contain the day of the month (like the 13th). What type is each variable? Assign values to those variables that represent today's date.

Display (output) the value of each variable on a line by itself. This is an intermediate step that is useful for checking that everything is working so far. Compile and run your program before moving on.

Modify the program so it displays the date in standard American format, for example: Monday, May 7, 2018.

Modify the program so it also displays the date in European format. The final output should be:

American format: Monday, May 7, 2018 European format: Monday 7 May 2018 

Exercise 2-3.

The point of this exercise is to (1) use some of the arithmetic operators, and (2) start thinking about compound entities (like time of day) that are represented with multiple values.

Create a new program called time.cpp. From now on, we won't remind you to start with a small, working program, but you should.

Following the example program in "Outputting Variables" on page xx, create variables named hour, minute, and second. Assign values that are roughly the current time. Use a 24-hour clock so that at 2pm the value of hour is 14.

Make the program calculate and display the number of minutes since midnight.

Calculate and display the number of seconds remaining in the day.

Calculate and display the percentage of the day that has passed. You might run into problems when computing percentages with integers, so consider using floating-point.

Change the values of hour, minute, and second to reflect the current time. Then write code to compute the elapsed time since you started working on this exercise. Hint:You might want to use additional variables to hold values during the computation. Variables that are used in a computation but never displayed are sometimes called "intermediate" or "temporary" variables.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!