Questions: 11 448

Answers by our Experts: 10 707

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Write a C++ program that creates two one dimensional arrays “A” and “B” of size 20 elements each. The main


program should get the input in the array “A” from the user and initialize array “B” with values “0”. Your


program should calculate the (number -2) of each element of array “A” and should store in the square value


in corresponding positions (index) in the array “B”. In the end, the main program (main function) prints the


calculated values of array “B”. Also display the values in array B which are Odd (if any).

The following code is supposed to display the positive even numbers less than 12. That is, it will

output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output

of the code below will be. Then write a small program including the code below and make the necessary

changes to fix the code so that it displays what it is intended to display. Ensure that your program works

correctly. Only submit the program, not the output.

Hint: Use variable diagrams to trace the program to help you find the logical error.

int x = 1;

while (x

!= 12)

{

cout << x <<

endl; x = x +

2;

}


The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be. Then write a small program including the code below and make the necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the output.


build registration system that allows users (Admin + Client) to create a new account by filling out all the attributes of its class. But, first, you need to create a binary file that will hold all the user data as objects.

Registration details stored in two separate files namely Admin.dat and Client.dat

These files have all data members including Usernames and Passwords.

After successful signup operations, you must show the menu to the user to Login into this system they must enter their username and password and you must verify these details from the files.

After login Users can reset their password and username. Password must be 8 characters long and use of minimum of one special character, uppercase, lowercase, and the numeric digit is a must. The passenger account is only created if a valid 13-digit CNIC is provided and CNIC must not be repeated in the existing

record. Otherwise, appropriate messages should be generated to notify the users. Users provide their basic identification details to register.


Include the for loop below in a small program and complete the program. The loop should execute 10vtimes. Do not change the for loop below. Compile and run your program to see for yourself that it works.You do not have to submit this program and output.

for (int i = 1; i <= n;

i++) cout << i * i;

Now convert the for loop into a while loop and add any variable initialisations that you think are necessary. Compile and run your program and submit only the program containing the while loop and its output.


The Computer Science Department follows certain criteria when a student learns to program. A

number of programming exercises must be worked through. To proceed to the next exercise a student has

to obtain a mark of 50% or more and must have completed 5 or more program runs. You are requested

to write a program to validate if a student can proceed to the next program.

Your program should have the following structure:

• Declare two integer variables programsDone and result.

• Validate the data captured for the two variables using a while loop.

• The loop should be repeated until the value of result is greater than or equal to 50 and the value of

programsDone is greater than or equal to 5.

• Display a message like "Good! You can now proceed to the next exercise"

Submit both your program and output.


You are requested to write a very simple calculator. Your calculator should be able to handle the five

basic mathematic operations – add, subtract, multiply, divide and modulus – on two input values.

Your program should have the following structure:

• Ask the user to enter two float variables named var1 and var2

• Ask the user to enter a character variable named operation to represent the operation to be

performed on the two variables.

• Perform the appropriate operation by using if-statements

• The output must be given in fixed-point notation with two digits after the decimal point.

A typical run is displayed below:

Please enter the first float value:

35.6 Please enter the second value:

24.12 Please enter the operation

required : + The sum of 35.6 and

24.12 is 59.72

Submit both your program and

output


Jennifer Yardley is the owner of Golf Pro, a U.S. company that sells golf equipment both domestically and abroad.


She wants a program that displays the amount of a salesperson’s commission. A commission is a percentage of


the sales made by the salesperson. Some companies use a fixed rate to calculate the commission, while others (like


Golf Pro) use a rate that varies with the amount of sales.


Golf Pro’s commission schedule is shown below, along with examples of using the schedule to calculate the


commission on three different sales amounts. Notice that the commission for each range in the schedule is


calculated differently.


Sales range


Commission


0 - 100,000 2%


100,001 – 400,000 5% over 100,000 and then add 2000


400,001 and over 10% over 400,000 and then add 17000


If the sales is less than zero, the program should display the message “The sales cannot be less than 0.”

In late 1990’s, the Department of Education started to get concern about the health of every public school students.



According to their research, a child performs well if he/she is getting the right nutrition their body needs. In order



solve this, they started a feeding program and monitors each student health records. Adapt the method of monitoring



the students’ Body Mass Index (BMi) helps the department to solve this concern . The body mass index (BMi) is



used to estimate the risk of weight-related problems based on a student’s height and mass. it was designed by the



mathematician Adolphe Quetelet in the 1800s and is sometimes referred to as the Quetelet index. The BMI is



computed as





In this formula, mass is in kilograms and height is in meters. The health risk associated with a BMI value are



• Underweight < 18.5



• Normal weight ≥ 18.5 and < 25



• Overweight ≥ 25 and < 30



• Obese ≥ 30

Write a complete program that prompts the user for the radius of a sphere, and calculates and

prints the volume of that sphere. Use a function sphereVolume that returns the result of the

following expression: (4/3) × π × r3 which is equivalent to

( 4.0 / 3.0 ) * 3.14159 * pow( radius, 3 ) in C++ code.

Sample output

Enter the length of the radius of your sphere: 2


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS