How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Programming
Satisfied Customers: 754
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Type Your Programming Question Here...
Ingo U is online now
A new question is answered every 9 seconds

1. Implement a class Car with the following properties. A car

This answer was rated:

1. Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a function drive that simulates driving the car for a certain distance, reducing the fuel level in the gas tank, and functions get_gas, to return the current fuel level, and add_gas, to tank up. Sample usage:
Car my_beemer(29); // 29 miles per gallon

my_beemer.add_gas(20); // Tank 20 gallons; // Drive 100 miles

cout << my_beemer.get_gas() << "\n"; // Print fuel remaining

2. Write a program that produces ten random permutations of the numbers 1 to 10. To generate a random permutation, you need to fill a vector with the numbers 1 to 10 so that no two entries of the vector have the same contents. You could do it by brute force, by calling rand_int until it produces a value that is not yet in the vector. Instead, you should implement a smart method.
- Make a second array and fill it with the numbers 1 to 10. Then pick one of those at random, remove it, and append it to the permutation vector.
- Repeat ten times.

Optional Information:
Computer OS: Windows 7
Programming Language: C++
when is this due,and what OS & dev tools are you using?
Ingo U
Customer: replied 3 years ago.

It is already past due. I have been working on these for 2 weeks and getting nowhere. I am using windows 7 64. Not sure what you mean by dev tools.



I'm guessing Visual Studio on windows? what version?
Customer: replied 3 years ago.

If you are asking about a compiler, I have been using a freebie on line. Here is the link.

OK, just open these in notepad, select all and paste them into your compiler window.

Hope they meet your needs!
Let me know if you have any problems.
Ingo U
Ingo U and 4 other Programming Specialists are ready to help you
Customer: replied 3 years ago.

For the second program.
I added a 10 times "for" loop. And got the same answers all 10 times. How can I throw a change in there so that every time I got truly different answers? I think I may be able to add to the first one a means to input different miles driven to change it up. Otherwise you did a GREAT JOB!! Thank you so much!

Sorry, missed the 10-run loop requirement.

As you'll see, you only want to call srand() once at the very beginning, then you'll get different random numbers every time through the loop and every time you run the program.


Related Programming Questions