Objects, classes, relationships, attributes, and methods
In: Computer Science
Write a C++ program using separate void which asks the user to input side of a square, radius of a circle , height and base of a triangle and finds the area of squares, circles and triangles. Then using main function display the area of square, circle and triangle
In: Computer Science
Thread Programming (C Programming)
Objective
Develop threads: thread and main.
Functionality of Threads:
The main program accepts inputs from the user from the console. The user can provide the following two types of input:
Here, num1 and num2 are two integer numbers.
E.g., the user may input add 1 2.
The threads receive the command along with the number, and performs the appropriate arithmetic operation and returns the results to main program. The main program then prints the results to the console. (The main program spawns 2 threads. The input from the user is then sent to the threads. One thread will do addition operation and the other one will do multiplication operation. The results will be sent back to the main program and print them out.)
Example of the threads usage.
Read Input Data for calculator Program
Create New Thread 0 for arithmetic operation.
Thread Started ID 0xb7ddab90
Lock Results for new operation:
Unlock Results after finishing new operation.
Result of add 1 and 2 = 3.00
Arithmetic operation Thread Stopped
Create New Thread 1 for arithmetic operation.
Thread Started ID 0xb75d9b90
Lock Results for new operation:
Unlock Results after finishing new operation.
Result of mult 3 and 4 = 12.00
Arithmetic operation Thread Stopped
In: Computer Science
Write a c++ program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows:
A = Any 5 digit unique number
B = A + 1000
Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29.
Rules:
You should first create a boolean function called isPrime and use that function in your program. This function should take in any int and return true if the number is prime, otherwise, return a false. In the main body of your program, you should create a loop from A to B (inclusive) and use isPrime function to determine if the loop number should be counted or not.
Your program SHOULD NOT PRINT the individual prime numbers. You can print them for your own testing purpose, but in the final submission, comment out such print statements.
Your program SHOULD ONLY PRINT the answer -- which is a number.
In: Computer Science
In PIC32-Embedded system. Give the value to be loaded in T1CON if the timer is used as counter with prescaler 1:64, synchronous, external clock source.
In: Computer Science
C++
Write a program that can be used to calculate the federal tax. The tax is calculated as follows: for single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of his or her gross income in a pension plan. the tax rates are as follows: if the taxable income is:
Prompt the user to enter the following information:
Your program must consist of at least the following functions:
To calculate the taxable income, subtract the sum of the standard exemption, the amount contributed to a pension plan, and the personal exemption, which is $1,500 per person. (Note that if a married couple has two children under the age of 14, then the personal exemption is $1,500 * 4 = $6,000.)
In: Computer Science
In the space provided below write a C++ program that asks the user to enter their quarterly earnings for the past two years stores the data in a 2-dimensional array. The program then computes both the annual earnings as well as the total earning and prints the results along with the 2-dimensional array on screen as well as onto a file.
In: Computer Science
please write in c using linux or unix
Write a program that will simulate non - preemptive process scheduling algorithm:
First Come – First Serve
Your program should input the information necessary for the calculation of average turnaround time including:
The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time.
Step 1: generate the input data (totally 10 jobs) and save it in the array of structure composing the arrival time, service time, termination time, turnaround time. The service time follows the uniform distribution in the range of [5, 25], and the arrival time is generated by uniform distribution in the range of [0,10] accumulated based on the previous arrival time.
Step 2: program FCFS algorithm.
Note: be careful about the situation that one job is finished while the next job is not arrived yet, so you have the idle time between them.
Step 3: output
print out one line for each job with arrival time, start time, service, termination time, turnaround time, finally average turnaround time in the last line.
IMPORTANT
please use random function for the arrival time
ex: arrival[1]= rand()%10
arrival[2]= rand()%11
arrival[3] = arrival[1]+rand()%11
In: Computer Science
What is Software Process Model (life cycle models)
In: Computer Science
Java:
int[]array={-40 ,60 ,78 ,-51 ,65 ,-95 ,77 ,-48 ,-66 ,71};
1) Create two int arrays called negative and positive of length 10. Go through the given array and place the negative values into the array called negative and the positive values into the array called positive.
2) Write code to find the smallest value in the given array and print the value out.
3) Write code to find the largest value in the given array and print it out.
4) Create an int array called flipped and reverse the sign of every number in the given array and place it in the flipped array.
In: Computer Science
In Statistics, a histogram is a graphical representation of data using bars of different heights. In a histogram, each bar groups numbers into ranges. Taller bars show that more data falls in that range. A histogram displays the shape and spread of continuous or discrete sample data.
In this project, you will write a program that creates a histogram that allows users to visually inspect the frequency distribution of a set of values.
REQUIREMENTS:
* Read from the data file the values in the range of 1-100 inclusive.
* Produce a histogram as shown in the expected output below to indicate how many input values fell in the range 1 to 10, 11 to 20, and so on.
EXPECTED OUTPUT:
run:
1-10 I*****
11-20 I******
21-30 I**
31-40 I*
41-50 I***********
51-60 I******
61-70 I********
71-80 I***
81-90 I****
91-100 I****
DATA FILE
51 68 42 61 23 50 79 9 12 9 67 85 64 97 41 13 66 47 54 2 46 48 11 52 79 48 73 48 51 15 44 97 19 48 53 13 58 47 95 2 1 65 84 28 89 99 70 67 84 36
In: Computer Science
Discuss the advantages and disadvantages of 2PL and Strick 2PL protocols. Beside the locking protocol, what is the additional requirement to ensure the transactional isolation property?
In: Computer Science
USING PYTHON ONLY
Part 3a: Prime Number Finder
Write a program that prompts the user to enter in a postive number. Only accept positive numbers - if the user supplies a negative number or zero you should re-prompt them.
Next, determine if the given number is a prime number. A prime number is a number that has no positive divisors other than 1 and itself. For example, 5 is prime because the only numbers that evenly divide into 5 are 1 and 5. 6, however, is not prime because 1, 2, 3 and 6 are all divisors of 6.
Here's a sample running of the program:
Enter a positive number to test: 5 2 is NOT a divisor of 5 ... continuing 3 is NOT a divisor of 5 ... continuing 4 is NOT a divisor of 5 ... continuing 5 is a prime number!
And here's another running:
Enter a positive number to test: 9 2 is NOT a divisor of 9 ... continuing 3 is a divisor of 9 ... stopping 9 is not a prime number.
Some notes on your program:
In: Computer Science
1.We sell music to our members. Employees recommend titles by rating them from1 to 5 with 1 being not very good to 5 being very good
What would your strategy be to write SQL code for the following query: "Show all the members and the sale dates of products they bought if they bought any products"
I would use a left outer join |
|||||||||||||||||
I would not use a join because the data comes from one table |
|||||||||||||||||
I would use an equality join to find matching records in two or more tables by matching primary and foreign keys |
|||||||||||||||||
I would use a subquery |
|||||||||||||||||
I would use a recursive join to join a table to itself 2. We sell music to our members. Employees recommend titles by rating them from1 to 5 with 1 being not very good to 5 being very good What would your strategy be to write SQL code for the following query: "Show every artist and product we carry and the sale date of the product it it has ever been sold"
|
In: Computer Science
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart instance should contain a BagInterface implementation that will serve to hold the Items that will be added to the cart. Use the implementation of the Item object provided in Item.java. Note that the price is stored as the number of cents so it can be represented as an int (e.g., an Item worth $19.99 would have price = 1999).
Your shopping cart should support the following operations:
Add an item
Add multiple quantities of a given item (e.g., add 3 of Item __)
Remove an unspecified item
Remove a specified item
Checkout – should "scan" each Item in the shopping cart (and display its
information), sum up the total cost and display the total cost
Check budget – Given a budget amount, check to see if the budget is large
enough to pay for everything in the cart. If not, remove an Item from the shopping cart, one at a time, until under budget.
Write a driver program to test out your ShoppingCart implementation.
Write a driver program to test out your ShoppingCart implementation.
Note that your implementation should be as generalized as possible. In other words, you should be able to create a ShoppingCart instance using any of the bag implementations and have all of the methods still work.
Also, think before you code. If you find yourself re-writing the substantive bag operations, you are doing it wrong.
And of course, your code should be documented with header comments for each method and in-line comments as needed.
In: Computer Science