Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I get this code to pass using these intructions: / / / / #include #include #include apex _ code.h #include using namespace

How do I get this code to pass using these intructions: //
//
#include
#include
#include "apex_code.h"
#include
using namespace std;
void minutes_to_12hour_time(stringstream &cin, stringstream &cout){
int minutes;
cin >> minutes;
int hours = minutes /60;
int minutes_remainder = minutes %60;
hours %=12;
cout hours ":" minutes_remainder "!" endl;
// Place code for translating minutes to 12 hour time
// Pretend this is your main function and you can use cin/cout
// as you would in main.
// If you want to print to the console for debugging use std::cout.
// Use cout for your final solution.
// First you want to get user input with cin
// Do any needed calculations
// Create output with cout
}
void numbers_to_12hour_time(stringstream& cin, stringstream& cout)
{
int hours =0;
int minutes =0;
int seconds =0;
char colonSign;
// Pretend this is your main function and you can use cin/cout
//reading input
cin >> hours >> colonSign >> minutes >> colonSign >> seconds;
hours += minutes /60.0;
minutes %=60;
hours += seconds /3600.0;
seconds %=60;
hours %=12;
//keep hours within 0 to 11 for 12 hour time
hours = hours %12;
//output hours, minutesm seconds
// Use cout for your final solution.
cout hours ":" minutes "." seconds "!" endl;
in this lab we will be coding two blocks of code (in apex_code.cpp), both translating time into a 12 hour clock. For our 12 hour clock, 12 o'clock will actually be 0
o'clock. So our hours range from 0 to 11, unlike an actual clock that have hours in the range 1 to 12.
This block of code gets a number of minutes from the user and translates that into time on a 12 hours clock. If the user puts 0 minutes into the program the
program should output the string "0:0!". The number before the colon is the number of hours, the number after the colon is the number of minutes. Here are some
more examples of input and output:
Input: "60"--> Output: ''
Input: "121"--> Output: '"
Input: "785"--> Output: "1:5!"// Notice the 12 hour clock time adjusts 13 hours to 1 hour.
HINT: There is a C++ operator that makes it easy to keep the hours between 0 and 11.
This block of code expands upon the first one. This time we will take the hours minutes and seconds from the user and translate to 12 hour clock time. The input
from the user is in the form "
image text in transcribed

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

Advances In Databases 28th British National Conference On Databases Bncod 28 Manchester Uk July 2011 Revised Selected Papers Lncs 7051

Authors: Alvaro A.A. Fernandes ,Alasdair J.G. Gray ,Khalid Belhajjame

2011th Edition

3642245765, 978-3642245763

More Books

Students also viewed these Databases questions