Question

Write a program that defines a Print Job structure as follows: 1) An integer job Id 2) A string user name (maximum 25 characters) 2 3) An integer tray (tray will hold the tray number 1 for 8 by 11 paper, number 4) An integer for paper size (this will hold a percentage: 100% is normal, 150% is 5) 1.5 times the size) page 1s together, all the A string for whether the pages are to be sorted (all the page 2s together) or stacked (1, 2, 1, 2, 1, 2, etc.) 6) A character for whether the documents should be stapled (Y or N) An integer coded for side (221 means to be printed double sided, taking 2 pages and turning it into 1 page, front and back; 121 means to be printed double sided, a double sided document; 111 means 1 side only to 1 side only or a from normal copy) 8) An integer number of copies 9) An integer status (1 means not printed, 0 means printed) Your program will load information from the file jobs.txt. Your program will read in an unknown number of jobs into an array max of 10). The reading of the files may be or you may create a function for this. Your program will utilize four functions: displayMenu(): Will print the following menu and ask for the users option. This function will return the choice to main. You must validate the users entry with a loop. zooooRocks Copy Menu Press 1 to print the next job Press 2 to see the jobs in the print queue Press 3 to see the job have finished printing Press 0 to quit Enter choice: printJob(): Will print the job from the top of the list. This function will turn the status from 1 (not printed) to 0 (printed) display Job(): Will display all the jobs in the list still to be printed. finished Jobs(): Will display all the jobs that have been printed.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
using namespace std;

int displayMenu()
{
    int choice; //To select choice.
    while(true)
    {
        cout<<"\nZooooRocks Copy Menu\n\n";
        cout<<"\nPress 1 to print the next job";
        cout<<"\nPress 2 to see the jobs in the print queue";
        cout<<"\nPress 3 to see the job have finished printing";
        cout<<"\nPress 0 to quit";
        cout<<"\n\nEnter choice: ";
        cin>>choice;
        if(choice >= 0 && choice < 4) //Checking for valid choice.
            break;
        else{
            cout<<"\nThe choice is not valid.\nPlease check the menu and try again.\n";
        }
    }
    return choice;
}

int printJob(string np[], string p[], int index)
{
    //np[] for not printed jobs, p[] for printed jobs, index for next job.
    int len;
    string curr_job;
    curr_job = np[index];
    len = curr_job.length();
    //Changing status.
    curr_job[len - 1] = '0';
    p[index++] = curr_job;
    cout<<"\n\nThe next job has been printed.";
    return index; //Returning next job.
}

void displayJob(string np[], int index, int len)
{
    int i;
    cout<<"\n\nThe unfinished jobs are:\n\n";
    for(i = index; i < len; i++)
    {
        cout<<np[i]<<endl;
    }
}

void finishedJobs(string p[], int index)
{
    int i;
    cout<<"\n\nThe finished jobs are:\n\n";
    if(index == 0) //If no jobs processed.
    {
        cout<<"\nNo finished job.\n";
        return;
    }
    for(i = 0; i < index; i++)
    {
        cout<<p[i]<<endl;
    }
}

int main()
{
    int i, choice, index = 0, len = 0;
    string curr_job;
    string notprinted[10], printed[10];
    ifstream jobs;
    jobs.open("jobs.txt");
    while ( getline(jobs, curr_job) ) //Reading file line by line i.e., job by job.
    {
        notprinted[len++] = curr_job; //Storing jobs into notprinted[] array.
    }
    jobs.close();
    while(index < len)//Loops when there are tasks.
    {
        switch(choice = displayMenu())
        {
        case 0:
            cout<<"\nExiting...\n\n";
            return 0;
            break;
        case 1:
            index = printJob(notprinted, printed, index);
            break;
        case 2:
            displayJob(notprinted, index, len);
            break;
        case 3:
            finishedJobs(printed, index);
            break;
        }
    }
    cout<<"\nAll jobs printed.\nExiting...\n\n";
    return 0;
}


Screenshot:

Zoooo Rocks Copy Menu Press 1 to print the next job Press 2 to see thejobs in the print queue Press 3 to see the job have fin

Add a comment
Know the answer?
Add Answer to:
Write a program that defines a Print Job structure as follows: 1) An integer job Id...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java coding. Create a class called Printer and a class called Job that will simulate a...

    Java coding. Create a class called Printer and a class called Job that will simulate a computer printer. The printer should store a queue of Job objects until they are printed. Each Job should consist of a title and the number of pages the job contains. The printer should also store the number of jobs it can print per minute. The class should include methods to add jobs and print jobs. The method that prints a job should return the...

  • Problems: 1. Write a program to define the following variables, assign them values, and print their...

    Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • Write a program which asks the user to enter an integer. Use switch statement to write...

    Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • Write a program that reads from the keypad an integer and calculates the following: If the...

    Write a program that reads from the keypad an integer and calculates the following: If the number given by the user is even, then divide it by 2. If it is an odd number, multiply it by 3 and add 1.The program should repeat this procedure for the calculated new result (which will be printed on the screen) until it reaches number 1. The program will also need to print out how many steps it took overall.

  • Assignment C++: Rock-Scissor-Paper & Tic-Tac-Toe i need you to write two different program for RSP and...

    Assignment C++: Rock-Scissor-Paper & Tic-Tac-Toe i need you to write two different program for RSP and TTT: R-S-P Requirement: - write one program that mimics the Rock-Scissor-Paper game. This program will ask user to enter an input (out of R-S-P), and the computer will randomly pick one and print out the result (user wins / computer wins). - User's input along with computer's random pick will be encoded in the following format: -- user's rock: 10 -- user's scissor: 20...

  • Write a Python program that asks users to input an integer number and print the summation...

    Write a Python program that asks users to input an integer number and print the summation of its digits and total number of its digits. (i.e., for n=35, sum is 3+5=8, and total number of digits is 2).

  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • Use C programming Make sure everything works well only upload Write a program that takes an...

    Use C programming Make sure everything works well only upload Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT