Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   Help with code (https://thetfp.com/tfp/tilted-technology/44121-help-code.html)

PoteMatic 02-03-2004 05:56 AM

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...

zenmaster10665 02-03-2004 06:09 AM

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...

;)

PoteMatic 02-03-2004 06:11 AM

Well this is the first actuall program we have done lol the class/teacher is not very good and I have not learned anything.

Fallon 02-03-2004 07:49 AM

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.

The_Dude 02-03-2004 09:13 AM

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 :D

PoteMatic 02-03-2004 09:23 AM

Alright well thanks for not just giving me the answer and giving me some advice instead. Ill get the book and try it.

numist 02-03-2004 09:28 AM

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...

PoteMatic 02-04-2004 06:32 AM

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

Artsemis 02-04-2004 06:41 AM

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

PoteMatic 02-04-2004 06:43 AM

Thanks

PoteMatic 02-04-2004 06:48 AM

Fixed um all and its runs fine thanks for all the help... I jsut got another assignment so will probably have some more questions.

nukeu666 02-04-2004 10:21 AM

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

nukeu666 02-04-2004 10:26 AM

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

PoteMatic 02-05-2004 05:55 AM

We are using borland im sick today kinda feelin run down not gonna do much ill get back to it tomorrow.


All times are GMT -8. The time now is 05:20 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, 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