C++ programs | Computer Science homework help

Hi,

I have these three simple programs.

 

 

1-

move the file input into a function, also
move the output to a function.

Finally, determine who is the oldest person
in the class, and then determine who the youngest
person is in the class

   

// Program Description: Arrays and Functions (and files), part 2

#include<iostream>
#include<string>
#include<fstream>

using namespace std;

int main()
{
    /*
Let’s write a shorter program which will prompt
a user for his/her first name, last name and
age.

    int number[] = {1, 44, 33, 2};
                    0   1   2   3

   

    cout << number[1];

    */
   
    const int x = 200;
    /*
    I am declaring a constant called x. I will use
    this value to allocate 10 blank pages for
    each array in my program.

    */

    string fName[x], lName[x];
    int age[x], a=0;

    ifstream iFile;
    iFile.open(“input.txt”);

    ofstream oFile;
    oFile.open(“output.txt”);

    while(iFile.good())
    {
        iFile >> fName[a];
        iFile >> lName[a];
        iFile >> age[a];
       
        a++;
       
    }
   
   
    a–;
    for(int b=0;b<=a;b++)
    {

        cout << “nnFirst Name: ” << fName[b] << endl;
        cout << “Last Name: ” << lName[b] << endl;
        cout << “Age: ” << age[b] << endl;

    }

   
    system(“pause”);
    return 0;
}

 

 

2-

what I want you to do:
move the horse position/drawing/etc code into a
function. Ideally, you would have the position
code inside of its own function

display the winner on the screen
: option 1: use a lot of if statements
: Option 2: use an array (easier)

 

// Program Description: Horse Racing Program

#include<iostream>
#include<time.h> // two libraries needed to
#include<stdlib.h> // generate random numbers

using namespace std;

    cout << horse << “: “;
    for(int b=0;b<=pos;b++)
        cout << ” “;
    cout << “~n-n^”;
    pos = pos + rand() % 2 + 1;
    cout << endl;

int main()
{
    int posA=0, posB=0, posC=0, posD=0; // counter to see where the horse
    // is currently, can then use it to redraw
    // the horse where he/she is needed
   
    // how can I make the below horse move?
    char horse;

    srand(time(NULL));
    // this line of code ensures that our program
    // will generate a NEW random number each
    // time we ask for one

    for(int a=0;a<=25;a++)
    {
        system(“cls”);
       
       
        horse=”A”;
        // call the function with the position
        // of the horse and the horse name

        for(int timer=0;timer<=100000000;timer++);

    }
       

    // Grant, I want to simulate this horse moving
    // across the screen, suggestions on how to
    // do it?

/*
I could redraw the horse each time the loop
iterates with the horse in a new position
?

*/

    cout << endl << endl;

    system(“pause”);
    return 0;
}

 

3-

 

I want a kiosk style system for my movie theater.
I want customers to be able to purchase movie
tickets and/or food/drink items from this kiosk.

The customer will get a receipt he/she can bring
to get food/drink items, and also ticket for
any movie he/she wants to see.

The program should have one total that the customer
would pay when the customer is finished using
the kiosk:

example: I  buy 2 movies tickets for a particular
movie and also buy 2 popcorns and 2 drinks.

Ideally, I would have a combo package where a
customer can have purchase tickets, food/drink
items for a discount.

The kiosk will accept credit cards only, therefore
you do not need to worry payment code in your
program

what I am looking for in your program:
Files for reading/displaying the available movies
Functions: should have functions for the movie
section, and also for food/drink items.

Finally, student discount of 10% if that person
has a student ID. If they do, then offer that
student a season pass for $100 which would allow
for unlimited movies for a the year

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more