Question

Exercise 1: Write a program to grade a set of true/false tests. There are 15 true/false questions. True is represented by T, and false is represented by F. The key to the quiz is on file quiz.dat, where it is followed by the student responses. Each students name (maximum of 15 characters) immediately follows the students last answer. For each student, write out the name followed by the number answered correctly and the number missed. Use stream failure to terminate processing. Exercise 2: An organization that your little cousin belongs to is selling low-fat cookies. If your cousins class sells more cookies than any other class, the teacher has promised to take the whole class on a picnic. of course, your cousin volunteered you to keep track of all the sales and determine the winner Each class has an identification number. Each sales slip has the class identification number and the number of boxes sold. You decide to create two arrays: one to hold the identification numbers and one to record the number of boxes sold. The identification numbers range from 1 through 10. Here is a sample of the data: ID Number Boxes Sold 23 4 13 4 10 16 The first time an identification number is read, store it in the next free slot in the array of identification numbers and initialize the corresponding position in the array of boxes sold to the number sold on the sales slip. Each subsequent time an identification number is read, add the number of boxes sold to the corresponding position in the array of boxes sold. You may assume that each class sold at least one box of cookies the homeroom mothers had to buy one When there are no more sales slips, scan the array of boxes sold for the largest value. The identification number in the corresponding position in the array of identification numbers is the class that wins.​C++ lang. Quiz.dat TFTFTFTFTTTFFFT
TFTFTFTFTTTFFFTJoe Jones
TFTFTFTFTTTFFFFJanet Jerome
TFTTTFTTTTTFFFTBetty Blaire
TTTFTFTFTTTFFFFBob Blaine
TFTFTTTTTTTFFFTRobby Roberts
FTTFTFTFTTTFFFTRobin Rogers
TFTFTFTFTTTFTTTCarla Cross
TFTFTTTTTTTFFFTCarl Cream
TTTTTTTTTTTTTTTNell North
FFFFFFFFFFFFFFFNed Nest
TFTFTFTFTFTFTFTDarla Darn
FTFTFTFTFTFTFTFDean Darling

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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


using namespace std;

int main(){

   ifstream fin("quiz.dat");

   if (!fin){
      cout << "Error opening file\n";
      return 0;
   }
   string ans;
   string str;
   int count = 0;
   getline(fin ,ans);
   //cout << ans << endl;
  
   while(getline(fin ,str)){
      int n = str.size();
      string name = str.substr(14,n-15);
      name = name.substr(1);
      int hits = 0;
      int miss = 0;
     
      for (int i = 0; i<15; i++){
          if (str[i] == ans[i]){
             hits++;
          }
          else
             miss++;
      }
     
      cout << "name:" << name << " ";
     
      cout << "Correct Answers:" << hits;
      cout << " " << "Incorrect answers:" << miss << endl;
      
   }
  
   return 0;
}

#include<iostream>
#include<fstream>

using namespace std;

int main(){

ifstream fin("input163.txt");
if (!fin){
      cout << "Error opening file\n";
      return 0;
}
int score[11];
int a, b;

for (int i = 0; i<10; i++){
      score[i] = 0;
}
while (fin >> a >> b){
     score[a] = score[a] + b;
}
int max = score[0];
int index = 0;
for (int i = 0; i<10; i++){
     if (max < score[i]){
        max = score[i];
        index = i;
     }
}
cout << "The winner is identifiction number " << index << " with score " << max << endl;

return 0;
}

C computer science ques (82 unread) - meenamanikç G substrin inc ++ -Google Se std:substro in C/c++ Gee + CentOS7-VMware Work

G Computer Science ques X(82 unread) -meenamaniks |G substrin inc ++ -Google Se | a stdsubstro in c/C++ -Gee + CentOS7-VMware

Add a comment
Know the answer?
Add Answer to:
​C++ lang. Quiz.dat TFTFTFTFTTTFFFT TFTFTFTFTTTFFFTJoe Jones TFTFTFTFTTTFFFFJanet Jerome TFTTTFTTTTTFFFTBetty Blaire TTTFTFTFTTTFFFFBob Blaine TFTFTTTTTTTFFFTRobby Roberts FTTFTFTFTTTFFFTRobin Rogers...
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
  • Need help with this programming please this is the instruction my teacher provided Write a C++...

    Need help with this programming please this is the instruction my teacher provided Write a C++ class called "Sales" and a main( ) function that uses the class. Also, write documentation of your project. Below is a specification of the class. . INTRODUCTION A company has four salespeople (1 to 4) who sell five different products ( to 5)1. Once a day each salesperson passes in a slip for each different type of product sold. Each slip contains: The salesperson...

  • C++ Background information: A company has four salespeople who sell five different products. Once a day,...

    C++ Background information: A company has four salespeople who sell five different products. Once a day, each salesperson passes in a slip for each different type of product sold. First on the line is the salesperson name, second is the product number, and third is the sales volume for this product by this salesperson in dollars. For example, the line Tara 2 200.00 means that salesperson Tara reported sales of volume $200.00 for product number 2. Data: Eric 1 200000.00...

  • Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive...

    Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive integer numbers from 1 to 999 (lottery numbers) and takes a single input from the user and checks the input against the 15 lottery numbers. The user wins if her/his input matches one of the lottery numbers. Your implementation must have a level of modularity (using functions) Functions you need to implement: Define function initialize() that takes array lotterNumbers[] as a parameter and assigns...

  • Please Write the following program in c# You are to write an application which will create...

    Please Write the following program in c# You are to write an application which will create a company, add agents (their name, ID, and weekly sales) to that company, and printout the details of all agents in the company. The application will contain three classes: Agent.cs, Company.cs, and CompanyTest.cs (this class is already provided). Flow of the application: The CompanyTest class creates an object of the Company class and reserves space for five agents. At this point if you call...

  • Mailboxes Java Peter the postman was bored one evening and he decided to experiment with the...

    Mailboxes Java Peter the postman was bored one evening and he decided to experiment with the mailboxes in the mailroom. The mailboxes were numbered from zero to 200 (there were 201 total mailboxes). Initially all boxes were closed. Starting with mailbox #2, he opened the door of every even numbered mailbox. Next, beginning with mailbox #3 and going to every third mailbox, he opened its door if it was closed and closed it if it was open. Then he repeated...

  • The following is for java programming. the classes money date and array list are so I are are pre...

    The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...

  • (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates...

    (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...

  • PART 1 Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is,...

    PART 1 Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is, if the list is full when an item is being added to this list, the elements will be moved to a larger array. The new array should have twice the size of the original array. Using the new class ArrayList, write a program to store 1,000 random numbers, each in the interval [0, 500]. The initial size of the array in the class should...

  • in java no mathcall please ennas are out of date.Please sign was wkollieemail.cpeedu so we can...

    in java no mathcall please ennas are out of date.Please sign was wkollieemail.cpeedu so we can verily your subscription Sign In ASSIGNMENT Unit 9 Methods, Arrays, and the Java Standard Class Library Reimplementing the Arrays class (60 points) The Arrays class, which is also part of the Java standard class library, provides various class methods that perform common tasks on arrays, such as searching and sorting. Write a public class called MyArrays, which provides some of the functionality which is...

  • The purpose of this problem is to practice using a generic Jar class. write in drjava...

    The purpose of this problem is to practice using a generic Jar class. write in drjava Create a generic class, called Jar, with a type parameter that simulates drawing an item at random out of a Jar. For example the Jar might contain Strings representing names written on a slip of paper, or the Jar might contain integers representing a random drawing for a lottery. Include the following methods in your generic class, along with any other methods you’d like:...

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