Question

In: Computer Science

Question 4 For a family day function at Wawasan Open University, the computer department is going...

Question 4

For a family day function at Wawasan Open University, the computer department is going to conduct quiz session to give prizes to the participants. They need the sample software to conduct this quiz session. The prototype software contains two sample questions.

First, display question 1. Give 30 seconds to answer the question, showing the countdown.

If answered correctly, move to question 2 else if time out or wrong answer, prompt other participants to try to answer with another 10 second before moving to next question. End the session.

language C

Solutions

Expert Solution

CODE FOR QUIZ QUESTION...

#include <iostream>
#include <conio.h>
#include <Windows.h>

using namespace std;

int main()
{
char ans, ans2, b=' ', e=' ';
int t=0;

for(int i=30;i>=1;i--)
{
system("cls"); //to clear the screen
cout<<"Timer: "<<i;
cout<<"\n\nQuestion Number 1? \n\ta) OPTION A \tb) OPTION B\tc) OPTION C d) OPTION D\n\n"<<"Your Answer: ";
if(_kbhit())
{
ans=_getch();
if(int(ans)==13){
e=ans;
}
else
b=ans;
}
cout<<b;
if(int(e)==13 && b=='d')
{
t=1;
break;
}
else
if(int(e)==13 && b!='d')
break;
Sleep(1000);
}

if(t==0)
cout<<"\n\nTIME IS UP | WRONG ANSWER.";
else
cout<<"\n\nCONGRATS! YOUR ANSWER IS CORRECT.";
goto Ques2;

Ques2:

return 0;
}

YOY CAN ALSO PLAY AROUND WITH FOLLOWING CODE FOR THE COMPLETE QUIZ...

#include <iostream>
#include <conio.h>
//to include functions from Windows API
#include <Windows.h>

using namespace std;

int main()
{
//declaring variables
char answer;
int t=0, b=' ', e=' ';

//setting the timer for 30 seconds
for(int i=30; i>=0; i--)
{
system("cls"); //clears the screen
cout<<"Timer: ";
cout<<i<<" "; //prints the time remaining
cout<<"\n\nTo confirm, press ENTER.";
cout<<"\n\nQues.1: This is the question?"<<endl<<endl;
cout<<"\ta) Option 1 \t b) Option 2 \t c) Option 3 \t d) Option 4"<<"\n\nYour Answer: ";

if(_kbhit()) //_khbit() to determine is a key has been pressed or not
{
answer=_getch(); //_getch() to get character from console without echo
if(int(answer)==13){
e=answer;
}
else
b=answer;
}
//matching the correct answer
if(answer=='b' || answer=='B')
{
//answer correct message
cout<<"\n\nCONGRATS! YOUR ANSWER IS CORRECT";

}

//if answer is incorrect
else
{
//answer incorrect message
cout<<"\n\n\nYour answer is incorrect. Looser!";

//display question again for 10 seconds for other participants
for(int i=10; i>=0; i--)
{
system("cls"); //clears the screen
cout<<"Timer: ";
cout<<i<<" "; //prints the time remaining
cout<<"\n\nOther participants can answer now.";
cout<<"\n\nQues.1: This is the question?"<<endl<<endl;
cout<<"\ta) Option 1 \t b) Option 2 \t c) Option 3 \t d) Option 4"<<"\n\nYour Answer: ";

if(_kbhit()) //_khbit() to determine is a key has been pressed or not
{
answer=_getch(); //_getch() to get character from console without echo

if(answer=='b' || answer=='B')
{
cout<<"\n\nCONGRATS! YOUR ANSWER IS CORRECT";
goto Ques2;
}
else if(t==0)
{
cout<<"\n\nYour time is up!";
goto Ques2;
}
else
{
cout<<"\n\n\nYour answer is incorrect. Looser!";
goto Ques2;
}
}
}
}
}

Ques2:

return 0;
}


Related Solutions

You are the head of a computer science department at a university. Your boss (a “dean”)...
You are the head of a computer science department at a university. Your boss (a “dean”) wants you to find a way to tweak your curriculum so undergrads are more likely to choose your department for their major. How would you respond in a way that islegal, moral, and ethical?
4. The department of HR at the University of Michigan wants to estimate the amount of...
4. The department of HR at the University of Michigan wants to estimate the amount of an annual healthcare premium needed for an Assistant Professor as part of a new recruiting program. In a sample of 50 Assistant Professors, they found that the average yearly premium needed is $16,000 with a standard deviation of $3,500. (a) What is the population mean? What is the best estimate of the population mean? (b) Develop an 90% confidence interval for the population mean....
Problem Description Students in Computer Information Systems (CIS) department at a local university are required to...
Problem Description Students in Computer Information Systems (CIS) department at a local university are required to do some group-projects in their classes because their instructors believe the skills and competence to work as an effective team are important to assure a successful IT project. Group project helps IT students apply system design knowledge, solve real world business problems, enhance learning effective team skills, improve students’ business communication skills, and serve back to the community. In order to ensure an effective...
In this question, we are going to call a function, f : R → R, type...
In this question, we are going to call a function, f : R → R, type A, if ∀x ∈ R, ∃y ∈ R such that y ≥ x and |f(y)| ≥ 1. We also say that a function, g, is type B if ∃x ∈ R such that ∀y ∈ R, if y ≥ x, then |f(y)| ≥ 1. Prove or find a counterexample for the following statements. (a) If a function is type A, then it is type...
4. The Athletic Department at State University has created numerous logos and designs foruse in their...
4. The Athletic Department at State University has created numerous logos and designs foruse in their merchandising program. For each logo and design, State University Athletics has sought and received federal trademark registration. The athletic department has recently hired you as a new assistant athletic director to oversee the merchandising program and to develop a licensing program for State University Athletics marks and logos. Upon your arrival, the new merchandising and licensing athletic director discovers that dozens of local businesses,...
Question 1. The math department needs a printer in the computer room of the second floor...
Question 1. The math department needs a printer in the computer room of the second floor of MSB, and the department is planning the purchase and maintenance schedule of the printer for the next six years. The cost of a new printer is $80, and it can be used for at most five years. The maintenance cost each year of operation is as follows: year 1, $30; year 2, $40; year 3, $60, year 4, $90; year 5, $100. The...
2. A University has completed an internal survey on its department achievements. The key question in...
2. A University has completed an internal survey on its department achievements. The key question in the survey is whether the professors think the new on-line system is effective. The following is the output of a statistical analysis of the data: Is online system effective Purpose No Yes Assignments 30 35 Labs and hand on activities 25 40 Exams 20 45 Based on this output, can the president conclude that the opinion of the professors on whether the recently launched...
Access control can be considered as the central element of computer security. Question 4(a), 4(b), 4...
Access control can be considered as the central element of computer security. Question 4(a), 4(b), 4 (c) and 4(d) based on this information. 4 (a). Relate the principal objective of computer security with the function of access control. 4 (b). Briefly explain how access control being implemented in the machine. 4 (c). If Process A requires 500MB of memory space to perform calculation and Process B requires 100MB of memory space to perform graphics processing, identify the object, subject and...
QUESTION FOUR Consider an open economy with the following specifications: Derive the savings function and show...
QUESTION FOUR Consider an open economy with the following specifications: Derive the savings function and show that .                               [3 marks] Define a budget deficit and state whether the government is in a deficit or surplus.                                                                                                                                             [3 marks] Given that the economy is open, state and explain the components of Aggregate demand (AD).                                                                                                         [4 marks] Derive the equilibrium income and clearly show the multiplier.                      [10 marks] What will be the impact on the equilibrium...
In this question, you should complete the C program, perfect.c, by implementing the function isPerfect. Open...
In this question, you should complete the C program, perfect.c, by implementing the function isPerfect. Open the file perfect.c, complete, compile and run it. When you are sure it is correct, include the c file in your final submission. * Note: You should first carefuly read the COMMENTS provided for the function isPerfect, and then start completing the function. * Note: You MUST NOT alter the main function and the prototype/header of the isPerfect function. ONLY develop the body of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT