The formula below decribes Newton's second law of motion
Force = Mass x acceleration
Using the variables below Write one line of code that will calculate the acceleration of a object.
// Mass in Kg
float mass = 50.3;
// Froce in N
int force = 720;
//acceleration
float accel;
//One line of code to calculate the acceleration of a object
//One line of code to calculate the acceleration of a object
Write a program that prompts the user to input height and width and print the hollow rectangle
as given in the output below. The program should check whether the both height and width
of rectangle are equal or not. Do not use nested loops.
In the Store class, make an ArrayList of customers, store name, and address implement methods
public void addSale(Customer c) that will add customers to the arraylist.
public void RemoveCustomer(int id);
public void UpdateCustomerRecord(int Id);
public displayAll();
public String nameOfBestCustomer() to record the sale and return the name of the customer with the largest sale.
public ArrayList nameOfBestCustomers(int topN)
so that it displays the top customers, that is, the topN customers with the largest sales, where topN is a value that the user of the program supplies.
In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.
Determine whether the following are valid switch statements. If not,
explain why. Assume that n and digit are int variables. (11)
a. switch (n <5 2)
{
case 0:
cout << "Draw." << endl;
break;
case 1:
cout << "Win." << endl;
break;
case 2:
cout << "Lose." << endl;
break;
}
b. switch (digit / 4)
{
case 0,
case 1:
cout << "low." << endl;
break;
case 1,
case 2:
cout << "middle." << endl;
break;
case 3:
cout << "high." << endl;
}
c. switch (n % 6)
{
case 1:
case 2:
case 3:
case 4:
case 5:
cout << n;
break;
case 0:
cout << endl;
break;
}
d. switch (n % 10)
case 2:
{
case 4:
case 6:
case 8:
cout << "Even";
break;
case 1:
case 3:
case 5:
case 7:
cout << "Odd";
break;
}
Suppose that sale and bonus are double variables. Write an if...else
statement that assigns a value to bonus as follows: If sale is greater
than $20,000, the value assigned to bonus is 0.10, that is 10%; If sale
is greater than $10,000 and less than or equal to $20,000, the value
assigned to bonus is 0.05, that is 5%; otherwise the value assigned to
bonus is 0, that is 0%.
What is the output of the following C11 code? (2, 5, 6)
int x = 15;
int y = 3;
if (x + y > 17 || y - x < 20)
{
y = x - y;
x = y + x;
cout << x << " " << y << " " << x + y << " " << y - x << endl;
}
else
{
x = y - x + y %5;
cout << x << " " << y << " " << x - y << " " << x + y << endl;
}
What is the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int firstNum = 28;
int secondNum = 25;
cout << firstNum << " " << secondNum << endl;
cout << (firstNum = 38 - 7) << endl;
cout << (firstNum <= 75) << endl;
cout << (firstNum > secondNum + 10) << endl;
cout << (firstNum >= 3 * secondNum - 100) << endl;
cout << (secondNum - 1 == 2 * firstNum) << endl;
cout << firstNum << " " << secondNum << endl;
return 0;
}
Write a program to calculate the average of
all scores entered between 0 and 100. Use a
sentinel-controlled loop variable to terminate the
loop. After values are entered and the average
calculated, test the average to determine whether
an A, B, C, D, or F should be recorded.