Write a program that calculates the intersection of two sets

Assignment Help Programming Languages
Reference no: EM131321345

Assignment

Write a program that calculates the intersection of two sets of numbers. The sets can be represented using arrays. The general idea is that A!=0 if i is in the set and A==0 if it is not.

Array element

A can thus be treated as a Boolean. Since the array has a fixed bound, say N, the values in the set are restricted to the range 0..N. For example, the array A[10]={0,0,1,0,1,1} would represent the set {2,4,5}, because A[2], A[4] and A[5] have value 1 and everywhere else A contains zeros.

The program should read two sets (arrays) of number s A and B. Then it computes the intersection and displays the results. Make N equal to 10.

Example

Enter number of elements in set A:

5

Enter set A:

0 4 2 1 6

Enter number of elements in set B:

3

Enter set B:

1 9 3

Intersection: 1

3. You are asked to implement a program that helps a school instructor to perform different operations on the scores of his students in a specific class.

The classroom has 10 students. Each student has performed 5 tests during the semester (each test is out of 100). Your program should do the following:

a. Declare an array of strings which stores the names of the students.

b. Declare a two dimensional array which stores the scores of the students.

c. Take the input data from a text file named "students.txt". The file contains the data of 10 students (i.e. the name of the student followed by5 scores). An example of the input file is shown below:

College of Arts & Sciences, Department of Computer.

d. Display a menu with the following options (the user should enter the number of the desired option):

1. Compute the average for each student. Then the program displays the name of each student along with his/her average.

2. Compute and display the name of the student with the highest average.

3. Compute and display the number of students who passed the course and the number of students who failed. Note that the passing score is 70.

0. Quit the program.

Reference no: EM131321345

Questions Cloud

Determine the apple kinetic energy : A 0.21-kg apple falls from a tree to the ground, 4.0 m below. Ignoring air resistance, determine the apple's kinetic energy, K, the gravitational potential energy of the system, U, and the total mechanical energy of the system, E,
Calculate and plot the lorenz curve : The Table below gives the income of each of four individuals who are in a region. Calculate and plot the Lorenz curve and calculate the Gini coefficient for this economy
Compare and contrast their global business competitiveness : Every country around the globe is competing for investments by multinational companies. However, before investing in a new facility overseas, each company takes a multitude of factors into account.
What is the force that the water exerts : A) What is the force that the water exerts on top of the can? B) What is the force that the water exerts on the bottom of the can? C) If the can has a mass of 2000 grams, what is the tension in the string?
Write a program that calculates the intersection of two sets : Write a program that calculates the intersection of two sets of numbers. The sets can be represented using arrays. The general idea is that A!=0 if i is in the set and A==0 if it is not.
Holders either at specific date after the date of issue : Bonds that can be redeemed at par at the option of their holders either at specific date after the date of issue and every 1 to 5 years thereafter or when and if the firm takes specified actions such as being acquired, acquiring another company, or i..
Analyze ocbc bank after reading this article : Analyze OCBC Bank after reading this article. Please click on the link, then click on the "Login in as subscriber to read the full article" located at the end of the article, then login with the credentials below. Search for "Putting the 'person' ..
Each project requires net investment outlay : Assume that you are the chief financial officer at Porter Memorial Hospital. The CEO has asked you to analyze two proposed capital investments – Project X and project Y. Each project requires a net investment outlay of $10,000, and the opportunity co..
Simple harmonic motion with an amplitude : A sewing machine needle moves up and down in simple harmonic motion with an amplitude of 1.27 cm and a frequency of 2.55 Hz. What is the maximum speed of the needle? ((answer: 20.3 cm/s))

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a program for a furniture company

Write a program for a furniture company that determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name of the wood chosen as well as the price of the table

  Values of variables of logical section of the pseudocode

What are the values of variables a, b, and c after each line of code of each logical section of the pseudocode. Show why the logical section is running.

  Read about what to look for when determining authenticity

Determine whether or not the author(s) provided reliable information supporting their argument/product.

  Write a program that takes a single directory as an argument

Write a program that takes a single directory as an argument, and iterates through all the normal files in the directory, and concatenate them to standard out.

  Prepare the equation as a vba statement

In environmental engineering, the given formula is employed to calculate the dissolved oxygen concentration in a river at a location x downstream from a sewage treatment plant effluent.

  Design program that uses cfswitch and cfcase structure

Your program must use the ColdFusion built-in function RandRange() to generate a random number between the ranges of 1 and 4, and assign this value to a variable called score.

  You have been hired by a school district

You have been hired by a school district to write a program that will grade multiple choice exams and providea report listing the grade (numeric and letter) for each student, the problems missed for each student.

  Create a sub called total to calculate sum for all number

Create a Sub called Total to calculate the sum for all numbers in Data file. Create a Sub called MinMax to determine the largest and smallest numbers in Data file. USE FOR EACH Loop!!

  Create a shell script that will list files in a directory

This option instructs the program to display a long listing. The output shall display the following column headers

  Design a logic for a program which allows a user to enter

design a logic for a program that allows a user to enter 15 numbers then display each number and its difference from

  Write program to accept name and score of all batsmen

Write a program to accept name and score of all batsmen of a team and print them in the given manner: INPUT:names[]={nam1,nam2,nam3,nam4,nam5,nam6} & scores[]={48,65,73,10,90,84}

  Create application which simulates functionality of gas pump

Create application which simulates functionality of gas pump. The user enters number of gallons to buy and clicks desired grade.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd