Write a program that will ask for a price. If the price is greater than 1000, compute a 10%
discount from the original price. Display the computed discount.
write a program that ask a user to enter a number n and display the first n even number
Write a Java application and use a Two dimensional array to store five Dutch, French and Italian translated words. Use a single array to store the English words.
Q.2.1 Contain a single array to contain the following five English words and a Two dimensional array to store the following Dutch, French and Italian translated words.
ITALIAN WORD
cielo
correre
studia
musica
cane
ciel
courir
etude
musique
chien
hemel
rennen
studie
muziek
hond
FRENCH WORD
Your program must:
ENGLISH WORD
sky
study
music
run
dog
DUTCH WORD
Build a class Department having id (int), address (String) and projects (array list of projects) and workers (array list of workers) a. Provide parameterized constructor Department (String address) which initialized id randomly and array lists as empty array lists. Provide in department class void addProjectWork(int pid, int wide, int hours)
This will add the hours to the worker of the given project. For this you will need to call the appropriate method of the project class i.e addMemberHours which adds the hours for the specified member as well as add to duration of the project
Build a class Project with id(int) , desc (String), duration (int) , budget (double) and members (ArrayList of Workers). a. Provide a parameterized constructor Project (int id, String desc, double budget). The member array will be initialized as empty array and the initial duration of the project will be 0 b. Provide setters for description and budget and getters for all except members list. Provide a method getTotalCost() that calculates the total cost of the project by summing the budget and the salary of each member of the project. The salary of each m ember can be found by calculating an appropriate method of the Worker class.
Write a program to plot a graph of function f(x) = x
n + xn-1
. Your program should take a maximum
absolute value of x as well as a positive integer n as input. You will plot a graph for the range [0, x]. You
should label the y-axis according to the maximum value of x.
Sample Output: For x = 3 and n = 2, you should have the following output
12 *
10
08
06 *
04
02 *
00 *
0 1 2 3
A perfect number is an integer that is equal to the sum of its factors. For example, 6 is a perfect number
as 6 = 3+2+1. Write down a program that takes an integer x as an input and prints all perfect numbers
from 1 to x.
A cannon ball is thrown straight into the air with velocity
v0. Position of the cannon ball after t seconds is given by, s = vi t – (1/2) gt.You are required to confirm equation by a simulation. In simulation, you will consider how the ball moves in very short time interval Δt.In a short time interval, the velocity v is nearly constant, and we can compute distance the ball moves using Δs = vΔt. Δt is a constant double with value 0.01. Get updated position using s = s + v * Δt. Velocity changes constantly—in fact, it is reduced by the gravitational force. In a short time interval, Δv = –gΔt, you must keep the velocity updated as v = v - g * Δt; In next iteration, new velocity is used to update distance.You need to run simulation until cannon ball falls back to ground. Take initial velocity as input. Update position and velocity 100 times per second, but print out the position only every full second. Also, printout values from exact formula s = vi t – (1/2) gt2 for comparison. Lastly plot path.
You are an employee of a marketing organization that pays you a monthly salary of Ksh. 10,000 if you work for the recommended 160 hours a month (Monday - Friday, 9am - 5pm, for a month). This salary can however fluctuate based on the number of hours worked, in that if you work for more than the recommended working hours ie above 160 hours, you earn an extra 10% of your salary but if you work for less than 160 hours, you will be deducted 10% of your salary. With the aid of a SWITCH CASE select structure Implement a program written in C++ that would help the finance department calculate your monthly salary based on the hours worked being the input value of the program.
Write a program that reverses the input number n. Formulate an equation to come up with the answer:
(Apply the three loop statements in your solutions) Sample input/output dialogue:
Enter a number: 1238 Input data
Reverse number: 8321 Output value
1st Solution using- for loop