Write a program that reads in a month of the year as a number (eg 1 for January, 4 for April) and then displays the number of days in that month. Keep in mind the impact of leap years. Note – Only for February the actual year is important (you should ask the user for the year of interest)
Implement a class MeraSet, which abstracts a mathematical Set of integral numbers. Maximum members can be 100. Implement following Member functions:
int Insert(int e) ; // adds value e to the set and returns 1, if the value already exists or the set has already 100 members, then it does not add and return -1.
int Size(); // return size of the set
int Remove(int e); // removes e from Set, and return 1. If e is not member of set, returns -1.
void Print(); // prints the members of the set in set notation e.g. Set = {1,2,3,8,-3 }
operator + ; // returns union of two sets
operator -; // returns difference set of two sets i.e. A-B
Make private member variables and more functions as you like.
Implement MeraSet2 class similar to last assignment, Add following members:
operator =; // assignment operator, makes deep copy
Copy constructor
operator []; // implement subscript operator, to display individual element of a set.
Numbers in String - 1
Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the digits of all numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
8
2.0
Sample Input 2
Tech Foundation 35567
Sample Output 2
26
5.2
Sample Input 3
Anjali25 is python4 Expert
Sample Output 3
11
3.67You've to develop table tennis fantasy league.Here're details of league:no. of team (4) and no. of player/team (3). Each team will have to play
other team twice,so you can calculate total number of matches.
1.addPlayers():add player data.
Sr. No. Name Type Point Availability
1 Name Player 1 Attacking 35.93 true
3.assignRanks(): Assign ranking to 4 teams on the basis of random number.
4.teamSelection(): Form team on basis of strategy,defensive team will prefer two defensive
players and one attacking player.Whereas an attacking team will prefer two attacking players and
one defensive player.
6.generateMatchStats():This function will generate match status.Assign winning team players’ point
b/w 10 & 20 randomly. For losing team assign them point between 5 & 10 randomly.
7.bestPlayersInMatch():Display information of best player of both teams
8.UpdatePlayerPoints():After match update ranking point of players
9.printLeaderBoard():Print sorted list of player in all teams
Briefly describe Insertion sort algorithm using the following array of numbers. 10, 5, 15, 3, 12 ii Write an algorithm in pseudocode for the Insertion sort. (15 marks ) (10 marks) Analysing the following algorithm given in pseudocode. After executing the program what will be printed on the screen, if n-5 and elements of the array A is initialized to (10,5,15, 3, 12), Write the steps to show how you decide your answer. I/ lambda 10 an array of n Funct (A, n) for 1=n-1 to 1 for 1 to i if A1 temp Al A(j) = A(j + 1) Aff + 11 = temp for 1 - 1ton print Alil A[j+1] elements -A(1,..n) (15 marks) According to the algorithm given in the above question 1.iii, how many times will the comparison statement be executed.
Mean, Median and Mode
Given a list of integers, write a program to print the mean, median and mode.
Mean - The average value of all the numbers.
Median - The mid point value in the sorted list.
Mode - The most common value in the list. If multiple elements with same frequency are present, print all the values with same frequency in increasing order.Input
The input will be a single line containing space-separated integers
Sample Input 1
2 4 5 6 7 8 2 4 5 2 3 8
Sample Output 1
Mean: 4.67
Median: 4.5
Mode: 2
Sample Input 2
2 6 3 1 8 12 2 9 10 3 4
Sample Output 2
Mean: 5.45
Median: 4
Mode: 2 3
.
convert to prefix:
( AX * ( BX * ( ( ( CY + AY ) + BY ) * CX ) ) )
What is the main difference between the PC and Apple?
Which of the following are not viewed as principles guiding design?
Numbers in String - 2
Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
35
17.5
Sample Input 2
Tech Foundation 35567
Sample Output 2
35567
35567.0