Click here to Skip to main content
15,867,306 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
Complete the provided main() program with statements to accomplish each of the following. In each case you must use the appropriate I/O stream manipulators to produce the appropriate output wherever possible. Refer to the sample output below as a guide for proper output alignment.

Output first first as an integer value, followed by a space, then in its written form.
Output second as a base ten value, followed by a space, then as a hexadecimal value, followed by a space, then as an octal value. Make sure the appropriate base indicator prefix is shown in the output.
Output third.
Output fourth with four digits, with the sign shown at the left, and the value right aligned. The decimal point must also appear.
Output fourth with four significant figures.
Output fifth with seven significant figures. (Must be left-aligned)
Output fifth with three digits to the right of the decimal point.
Output third.
Output fourth with two digits to the right of the decimal point.
Output sixth with no decimal portion showing
Output fourth with eight digits to the right of the decimal point.
Output sixth with six digits.

You must start your coding by using exactly the following program. You may not modify it, except to add the required code between the Solution starts, and Solution ends comments.
#include <iostream>
#include <iomanip>
using namespace std;
int
main()
{
    bool first;
    int second;
    long third;
    float fourth;
    float fifth;
    double sixth;

    cout << "Enter bool, int, long, float, float, and double values: ";
    cin >> first >> second >> third >> fourth >> fifth >> sixth;
    cout << endl;

// ***** Solution starts here ****

// ***** Solution ends here ****

    cin.get();
    return 0;
}

SAMPLE PROGRAM OUTPUT (assume user inputs values shown in bold):
Enter bool, int, long, float, float, and double values:
1 69 1464878 6443.39 -7.273 -6443.39
1 true
69 0x45 0105
1464878
+ 6443.
6.4434e+03
-7.2729998e+00
-7.273
1464878
6443.39
-6443
6443.39013672
-6443.39
Posted
Updated 20-Feb-13 10:56am
v2
Comments
Marco Bertschi 20-Feb-13 17:04pm    
Sarah,
please do not take this as an insult - are you trying to get us to finish your homework?
Oh and by the way: It seems like you forgot to set the user inputs' fond to bold (right after you souce block).
Edit: We are trying to help you with homework if you can show us the effort you have done until now and can show us a paticular example where an error does occur.
I only can start explaining thcode lines which you already have submitted:
cout << "Enter bool, int, long, float, float, and double values: ";
Writes the sentence between the "" out to the console.

cin >> first >> second >> third >> fourth >> fifth >> sixth;
Reads the variables' values from the console - starting with variable "one" and ending with "six".

I can maybe help you if you tell me what you have tried until now and explain me why you are stuck.

cheers,
Marco Bertschi
Sarah Trattner 20-Feb-13 17:25pm    
No I just need some clarification on cout << setprecision....etc. The professor I have takes zero time to explain anything for us newbies and I feel like; even though I'm hardware/software inclined that programming is going to kick my <<bleep>> if I don't get some extra help.
Marco Bertschi 20-Feb-13 17:36pm    
You can always get extra help on codeproject as long as you follow some basic rules:
- Be kind
- DO NOT SHOUT
- Tell us what you have done by now
- Tell us why you are stuck
- Pinpoint where you need the help (in your case: Can someone explain me the cout<< and cin >> setpession in this code sample?)
- You can submit questions about the C++ progamming language at the corresponding forum:
http://www.codeproject.com/Forums/1647/C-Cplusplus-MFC.aspx
The experts are there and you usually can get an answer much faster than herre in the Q & A section

About the cin / cout thing: Maybe this link below is going to help you:
http://www.cplusplus.com/doc/tutorial/basic_io/

And we stand fully behind every one whos teacher is a complete moronic <otherinsulthere> who cannot explain stuff to his students.
Valery Possoz 20-Feb-13 17:34pm    
What a silly assignment! I don't think that using riddles to teach programming is very clever... lewax00 solution points you articles showing how to format outputs.
Marco Bertschi 20-Feb-13 17:38pm    
Slow down, it is a beginners tutorial. She will se lewax00' solution by herself.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900