Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range of 0 through 9 for each element in the array.
The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that match. For example, the following shows the lottery array and the user array with sample numbers stored in each. There are two matching digits (elements 2 and 4).
lottery array: 7 4 9 1 3
user array: 4 2 9 7 3
The program should display the random numbers stored in the lottery array and the number of matching digits. If all of the digits match, display a message proclaiming the user as a grand prize winner.
Input Validation: Do not accept a negative value for lottery number. Also keep track of array size.
(Repetition structure, while loop)
You are to write a program in C++ that will perform several conversions. The program should display a menu that will have the following options:
1. Convert Kilobytes to Megabytes.
2. Convert Megabytes to Gigabytes.
3. Convert Gigabyte to Terabytes.
4. Quit.
The program should receive the amount to convert to a specific unit and return the result of that conversion. The program should run several times until the user decides to quit it. Make sure that the program is well indented, free of bugs and logical errors.
Structures - 14 points
Appropriate variable names/data types - 8 points
Input/Output Statements/Menu - 12 points
Calculations - 8 points
Comments - 8 point
Write declaration of binary tree which is suitable for Book pseudo code. Read pseudo code from book (introduction to algorithm edition 3 by thomson) and convert into C++ code. The function need to be implemented. Insertion, Deletion, Maximum, Minimum, Successor.
JamEx Limited requires a program to calculate and print the commission received by a salesperson. The program should process an undetermined number of salespersons and appropriately terminate by a predefined input. The commission rate is based on two factors, the amount of sales and the class to which a salesperson belongs. The input will be the salesperson number, sales amount and class. The commission rate will be based on the following criteria:
Class=1
If sales is equal to or less than $1000, the rate is 6 percent.
If sales is greater than $1000 but less than $2000, the rate is 7 percent.
If the sales is $2000 or greater, the rate is 10 percent.
Class=2
If the sales is less than $1000, the rate is 4 percent.
If the sales is $1000 or greater, the rate is 6 percent.
Class=3 The rate is 4.5 percent for all sales amount
Class=any other value
Output an appropriate error message.
Design an algorithm to read a value from the keyboard which represents the name of a shape. Allowed shapes are circle, parallelogram, and triangle, any other shape name should result in an error message being displayed. If the user enters parallelogram, then they should be asked to indicated between rectangle or square. For triangles, only right-angled triangles are allowed.
For each shape the area of the is to be calculated and displayed so the program should prompt the user for any additional information needed to calculate the area based on the shape. The calculated area along with the input from the user should be displayed.
Draw the flowchart and write the pseudocode for the algorithm. Implement the algorithm in C++.
a) Write a method GetOneStudent that asks a student for both of his/her WRAV101 and
WRSC111 marks (each as a real number). The method must return both of these marks. The
method must ensure that each of the marks is in the range 0 to 100.
b) Write a method CanContinue that takes as input two marks, one for WRAV101 and one for
WRSC111. Each of these marks is in the range 0 to 100. The method must return the value
true if both of these marks are at least 50, otherwise the method must return the value false.
Given a linked list containing n nodes. The problem is to insert a new node
with data x at the middle of the list. If n is even, then insert the new node
after the (n/2)th node, else insert the new node after the (n+1)/2th node
Suppose we have a pointer to float data type which contains the memory address
value 100.
If we add the integer value 3 to this pointer, what will be the value of the pointer if float data
types are 4 bytes in length?
A company Digicom Parts manufactures 2 types of unique products for laptop and desktop computers. It manufactures 10 types of laptop products and 42 types of desktop products. Each product manufactured by the company has a unique productID from a-z and A-Z. The laptop product have productID (a, i, e, o, u, ALE, O, U) while the rest of the productIDs are assigned to the desktop products. The company manager wishes to find the sales data for the desktop products. Given a list of productIDs of the sales of the last N products, write an algorithm to help the manager find the productIDs of the desktop products.
Read about doing multiplication using Karatsuba method
Write a C++ program which:
• Prompts user to enter two large integer numbers (x, y).
• Make a function called Karatsuba() which takes these two integers and returns the
multiplication result using Karatsuba algorithm.
o Your function should do parameter validation. Both numbers must be more
than 4 digits and less than 10 digits (don’t use strings). If parameters are not
valid then the function should return 0;
o The entered numbers could be negative or positive. For example: 820778 and
-58712979 where x is 6-digit positive number and y is 8-digit negative
number.
• You might need to make another helper function called getDigits() which will get an
integer as input and returns number of digits of that integer. getDigits() will help you
find the value of m and Bm.
• Finally, display result in the main function