12,452,344 members (55,462 online)
Rate this:
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 20-Feb-13 10:54am
Updated 20-Feb-13 10:56am
v2
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

http://www.cplusplus.com/doc/tutorial/basic_io/

And we stand fully behind every one whos teacher is a complete moronic 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.
Sarah Trattner 20-Feb-13 17:46pm

Thank you to everyone. I will try the link and the forum as well. Valery, I agree, on our Professor rating site he ranks at a "1" for his communication and teaching skills. I now see why. I literally was in tears yesterday when he attempted to explain this assignment. Apparently I am supposed to already know C++ before taking the class (wow).
Sarah Trattner 20-Feb-13 17:47pm

@Marco, I never take anything as an insult unless it starts off with "You are a....".
Thank you for your time and suggestions.
CHill60 20-Feb-13 18:42pm

Sarah ... Good Luck, keep working hard. Hope you work your way through the ... erm ... less than helpful teachers. Head Up! :-)

Rate this:

Solution 1

Top Experts
Last 24hrsThis month
 Maciej Los 240 ppolymorphe 225 Richard MacCutchan 140 Dave Kreskowiak 130 OriginalGriff 110
 OriginalGriff 6,163 ppolymorphe 3,820 Karthik Bangalore 3,585 Maciej Los 3,245 Richard Deeming 2,835