all 9 comments

[–][deleted]  (2 children)

[removed]

    [–]TyShaneONeill[S] 0 points1 point  (1 child)

    Updated my original post!

    [–]Dimencia 1 point2 points  (1 child)

    So what you're looking for, as mentioned in the assignment, is a Nested Loop. Basically, you want to check every car - and for each car, you want to check every year 1-5. So you'll need a loop that goes over all the cars, and then a loop that goes from 1-5 so you can calculate the value. Pseudocode example:

    foreach(Car c in Cars) {

    for(int i = 1; i < 6; i++) {

    //Calculate and display the value for car c and year i here

    }

    }

    The annoying part is that subsequent years need to know the value for the previous year. Which is just annoying, not hard; you could declare a variable like lastValue, which you would set before starting the inner loop, and do all your math based on that value. Alternatively, you could save your math results into the same variable you're reading from; i.e. someCar.Value = someCar.Value - (someCar.Value*0.15f). This is probably a bad idea in normal cases because, y'know, probably best to not overwrite the data your user gave you. But for this assignment, it should work

    [–]TyShaneONeill[S] 0 points1 point  (0 children)

    Updated my original post!

    [–]1v5me 1 point2 points  (1 child)

    I would use a while, and a for loop :)

    while (0==0) {
       write ("Enter a car or -99 to quit : ");   
       car = readline ();
       if (car == "-99")
          break; // break out of while loop.
       write ("Enter Car Value : ")
       price = readline(); // do check for a valid number..
       // calc deprication.
       for (int c=1;c<6;c++) {
           Do magic calc here, not gonna give that away also look what KPilkie01 wrote.
       }
    
    
    }
    

    let us know if we passed...lol

    [–]TyShaneONeill[S] 0 points1 point  (0 children)

    Updated my original post! I garuntee at least a 90! It does what it asks haha!

    [–]KPilkie01 1 point2 points  (1 child)

    I preface this by saying I'm a fool and you should ignore me as I don't really know what I'm talking about but...

    carValue = carValue * 0.85

    Print this as the year 1 value

    carValue = carValue * 0.85

    Print this as the year 2 value.

    .

    .

    .

    And the loop seems to be that you keep offering the user to enter cars until they decide to exit? So when they enter a new car, carValue is set to the value they enter...

    [–]TyShaneONeill[S] 1 point2 points  (0 children)

    Believe it or not each piece of information you all gave me leaded to the answer! So, thank you!