#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:
Write a program that defines a Print Job structure as follows: 1) An integer job Id...
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 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 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 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 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 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 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 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 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 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...