Need helping writing a code

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Write a program that creates an integer variable and then assigns a random number to it. Ouput the variable and verify it falls between the maximum and minimum for the range you set. Answer the following questions:
1. Does the number ever fall outside of the range of numbers from the minimum to the maximum?
2. Does it ever equal to the minimum or maximum?
Challenge:
Have your program from above prompt the user for the minimum and maximum values and then output the number between the numbers they specified.
Fantasy Game

In a new role-playing fantasy game players must design their characters by picking a point value for each of three characteristics:

Strength, from 1 to 10
Health, from 1 to 10
Luck, from 1 to 10
Write a program that asks for a name for the character and asks for the point value of for each of the three characteristics.

However, the total points must be less than or equal to 15. if the total exceeds 15, then 5 points are assigned to each characteristic.

Use tabs to format your output. Output should be in columns and centred horizontally on the screen. A sample of the expected output information is below:

 

 

***
Welcome to Yertle's Quest
**

Enter the name of your character:
>>

Chortle Enter Strength (1-10): 
>> 8 

Enter Health (1-10): 
>> 4
Enter Luck (1-10):
>> 6

You have give your character too many points! Default values have been assigned:

Character Name: Chortle: ============================

Strength:  5 
Health:     5 
Luck:        5

To accept default values enter     Y
To reassign values enter             N

>> N  
Last edited on
Hello Rango123321,


PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

Along with the proper indenting it makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you.


You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.



I would start with:

Write a program that creates an integer variable and then assigns a random number to it. Output the variable and verify it falls between the maximum and minimum for the range you set. Answer the following questions:

1. Does the number ever fall outside of the range of numbers from the minimum to the maximum?
2. Does it ever equal to the minimum or maximum?


Write the code for this then post it before you continue. Compile often and fix all the errors and warnings that you receive. Get this part working first before you add the rest.

Andy

Edit:
Last edited on
:-\

"PLEASE ALWAYS USE CODE TAGS" applies to code and the like, I assume...

Lines 1 - 17 don't look like code to me -- they look like the problem statement -- so should not be in the "code block".

Line 23 - 49 look like they should be in a (program output) block, though.

Andy
Hello Andy,

Yes code tags mostly apply to code, but there are times when they become useful when trying to highlight something in a line. The "quote" and "output" tags do not work in the middle of a line.

And yes an "output" tag would have been better, but for what is there no tag would also work. I am just happy that he learned what he did wrong and corrected it.

If you saw the OP what was there was just the closing code tag.

After that it is just learning, trying and looking at what people do in other posts.

Andy
The problem is that the normal text (problem statement) is now harder to read as it disappears off the side of my screen.

I very much agree with you that the appropriate tag should be used. This comment was directed at the OP -- to put code/output in tags but not regular text.

Andy

ASIDE If you're new to this forum, please read a few posts to see how to present a question. Code fragments, nicely tagged and clearly formatted. And just fragments of problem code rather than huge bits of code. (If you can encapsulate your code as a small runnable program, thanks to http://cpp.sh/ , then all the better.)

ASIDE I also hold with the coding standard that line lengths should be limited to a maximum of 80 (or maybe 90 nowadays) characters. This hopefully sinks in once you've worked with code long enough to realise how much easier this makes your life when you're using diff tools and debuggers. It is also easier to read on forums like this!
Last edited on
Topic archived. No new replies allowed.