A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges P120.00 per hour for labor. Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. The program should have functions that return the following data:
· The number of gallons of paint required
· The hours of labor required
· The cost of the paint
· The labor charges
· The total cost of the paint job
Then it should display the data on the screen.
A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a C++ program using a function that takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the function in a complete C++ program.
A ball is thrown vertically upwards with an initial velocity of 30 m/s.
Using a time step of 0.02 s up to 6.20 s, write a matlab code to give a plot of the vertical distance versus
time for this ball.
Hint ; Motion under gravity is described by the equation : 𝑣𝑦 = 𝑣𝑜𝑦𝑡 +1/2𝑔𝑡²
and gravitational acceleration 𝑔 is here taken as negative.
Create a Java application that will Create a class called Team that will be used for creating team objects.
Data Members:
Name, HomeGround, and Goals.
Methods:
A default constructor which will initialize all data members to proper initial values
An overloaded constructor which receives two arguments; a team name and home ground name and it should also initialize the goals to a proper initial value
scoreGoals() should be 0 to 4 goals which will choose random number in that range
getName(), getHomeGround(), getGoals(), create get methods for each data member
In the main function use your classes to create object and demonstrate their functionality.
Create two team object prompt the user to enter the team name and the home ground name of each. Create Match object initializing it with the two team objects created above. Simulate play by calling the PlayMatch method of the Match object. Note that the isDrawMatch method should be called to determine if match is draw and display different output
Write a program to solve a quadratic equation ax2 + bx + c = 0. Always check if the discriminant (D)
> 0, then the equations has two roots
= 0, then the equation has one root (two equal roots)
< 0, the equation has no real roots
where D = square root of b2 - 4ac
. Rewrite the following expressions using an if...else statement. (Assume that all variables are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;
Which of the following apply to the while loop only? To the do...while loop only? To both?
a. It is considered a conditional loop.
b. The body of the loop executes at least once.
c. The logical expression controlling the loop is evaluated before the loop is
entered.
d. The body of the loop may not execute at all.
Write a Python program that asks the user for a range (a starting number and an ending number) and then counts how many numbers are prime numbers and how many numbers are perfect numbers between that range. It also prints those numbers in the format shown in the output of the example given below.
Hint (1): We may declare two strings/lists to store the prime and perfect numbers. Inside the loop, we check for prime and perfect numbers and add them to respective string/list besides counting them.
Hint (2): We may need to convert numbers in String to integers for checking and calculations. We may again need to convert numbers to Strings for storing and printing as the outputs shown in the example below.
Example: If the user gives us a range of between 2 and 6, there are 3 prime numbers (2, 3, 5) and 1 perfect number (6) in that range.
Input:
2
6
Output:
Between 2 and 6,
Found 3 prime numbers
Found 1 perfect number
Prime numbers: 2, 3, 5
Perfect number: 6
Rewrite the following expressions using an if...else statement. (Assume that all variables are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;
2. Suppose that x, y, and z are int variables, and x = 10, y = 15, and z = 20. Determine
whether the following expressions evaluate to true or false:
a. !(x > 10)
b. x <= 5 || y < 15
c. (x != 5) && (y != z)
d. x >= z || (x + y >= z)
e. (x <= y - 2) && (y >= z) || (z - 2 != 20)
3. Rewrite the following expressions using an if...else statement. (Assume that all variables
are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;