C++ programs | Computer Science homework help

Hi,

I have these three simple programs.

Don't use plagiarized sources. Get Your Custom Essay on
C++ programs | Computer Science homework help
Just from $13/Page
Order Essay

 

 

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

Calculator

Calculate the price of your paper

Total price:$26
Our features

We've got everything to become your favourite writing service

Need a better grade?
We've got you covered.

Order your paper