Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 02-03-2004, 05:56 AM   #1 (permalink)
Registered User
 
Help with code (C++)

Ive been behind and i just got an assignment but dont know how to do it so im gonna ask for some help.

The instructions are as follow:

1. Name the program ch4grade.cpp

2. Make sure the program name and the author's name is in comments at the top of the page

3. Put COMMENTS before EACH SECTION

4. Declare 5 char constants:
GRADE_A initialized to 'A'
thru
GRADE_F initialized to 'F'

--- compile your program here ---

5. Declare a char variable named myGrade

--- compile your program here ---

6. Assign the grade you'd like to recieve in this class to my_grade equal to in one of the constants GRADE_A thru GRADE_F.

--- compile your program here ---

7. Display your grade with a cout statement that says something like:
My name is xxxx.
The grade I'd like to recieve in C++ is...

-- compile and run your program ---


I have no clue on how to do any of this...

Last edited by PoteMatic; 02-03-2004 at 06:17 AM..
PoteMatic is offline  
Old 02-03-2004, 06:09 AM   #2 (permalink)
Bokonist
 
Location: Location, Location, Location...
Not trying to be rude, however, how did you make it to Chapter 4 without knowing how to:


1. Name a program ch4grade.cpp

2. Make sure a program name and the author's name is in comments at the top of the page

3. Put COMMENTS before EACH SECTION

4. Declare char constants:

5. Declare char variables...

__________________
"Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before.
He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way."
-Kurt Vonnegut
zenmaster10665 is offline  
Old 02-03-2004, 06:11 AM   #3 (permalink)
Registered User
 
Well this is the first actuall program we have done lol the class/teacher is not very good and I have not learned anything.
PoteMatic is offline  
Old 02-03-2004, 07:49 AM   #4 (permalink)
Junkie
 
Location: RI
Do you have a book? Cause that's how I learned all my stuff.
Try writing the program first, because it's a pretty easy assignment. If you have troubles after writing it, post your code on here, and someone will be able to help.
Fallon is offline  
Old 02-03-2004, 09:13 AM   #5 (permalink)
The GrandDaddy of them all!
 
The_Dude's Avatar
 
Location: Austin, TX
yeah buddy, if we help u out with stuff like this, you will never get anywhere.

i say you turn to the section on variable declarations and take it on from there.

good luck
__________________
"Luck is what happens when preparation meets opportunity." - Darrel K Royal
The_Dude is offline  
Old 02-03-2004, 09:23 AM   #6 (permalink)
Registered User
 
Alright well thanks for not just giving me the answer and giving me some advice instead. Ill get the book and try it.
PoteMatic is offline  
Old 02-03-2004, 09:28 AM   #7 (permalink)
Banned
 
Location: UCSD, 510.49 miles from my love
declaring a variable is an easy process:

typeofvar varname = initializedvalue;

for constants, like your GRADE_A - GRADE_F, you want to use the const modifier so the program cannot change the values after they have been initialized.

Assigning values is a simple mathematical operation, so Ill leave that out.

As far as printing, there are a few functions you can use, I reccoment you lookup the man pages (or go online) for cout.

Oh yeah, and read through that book...
numist is offline  
Old 02-04-2004, 06:32 AM   #8 (permalink)
Registered User
 
So far ive got

So far for my code i have

Quote:
//Variables and Constants
//
//Author: J-Bo

#include <iostream.h>

main()
{
//Part4 - declare variables
int grade. b;//b will be used to hold age
float a;//a will be used to hold temperature

//Part 5 - declare constants
const float TEMPERATURE=72.5;
const int YOUR_AGE=16;

//Part6 - intalize variables
a=TEMPERATURE;
grade=11;
b=YOUR_AGE;


//Part 7 - Display the results

cout <<"I am in grade " << grade << " at Osceola High" << endl


return 0;
}
When compiled i got three errors I cant find um so let me know if you can
PoteMatic is offline  
Old 02-04-2004, 06:41 AM   #9 (permalink)
Insane
 
Location: West Virginia
Your compiler should give you hints; always start with the top error in the list and recompile.

Here's what I see at a glance:
int grade. b;//b will be used to hold age

Should be:
int grade, b;//b will be used to hold age


and you need a semicolon at the end of your cout statement
__________________

- Artsemis
~~~~~~~~~~~~~~~~~~~~
There are two keys to being the best:
1.) Never tell everything you know
Artsemis is offline  
Old 02-04-2004, 06:43 AM   #10 (permalink)
Registered User
 
Thanks
PoteMatic is offline  
Old 02-04-2004, 06:48 AM   #11 (permalink)
Registered User
 
Fixed um all and its runs fine thanks for all the help... I jsut got another assignment so will probably have some more questions.
PoteMatic is offline  
Old 02-04-2004, 10:21 AM   #12 (permalink)
Junkie
 
nukeu666's Avatar
 
Location: India
what youu really need is to learn cpp SYNTAX!!!
get any book and read the 1st few chapters...atleast the semicolon/;, stuff will be clear
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up?
Because Oct(31) == Dec(25)
nukeu666 is offline  
Old 02-04-2004, 10:26 AM   #13 (permalink)
Junkie
 
nukeu666's Avatar
 
Location: India
Quote:
When compiled i got three errors I cant find um so let me know if you can
al compilers i've sen always tell you the line number where the errors are...
which compiler are you using?
i think you can download borlands compiler for free after registering on their site
devCPP is also a free compiler
__________________
Why did the Comp. Engineer get X-mas and Halloween mixed up?
Because Oct(31) == Dec(25)
nukeu666 is offline  
Old 02-05-2004, 05:55 AM   #14 (permalink)
Registered User
 
We are using borland im sick today kinda feelin run down not gonna do much ill get back to it tomorrow.
PoteMatic is offline  
 

Tags
code


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 11:55 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360