Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Homework -

Q1. (Debugging) - No partial credit if you couldn't fix all errors.

Fix the errors in the attached C code. The indentation indicates the desired behavior for the if statement.

Q2. (Formatting)

Write, compile and run the following code in repl.it. You may see different values for (3/2) using different data types and different conversion specifier while we expect to see (3/2=1.5). Simply justify each output seen using a comment for each output in your code. For some cases different compiler, might show different values. You don't need to explain the exact values. Just explain the reason as best as you can.

Q3. (Sales-Commission Calculator)

One large chemical company pays its salespeople on a commission basis. The salespeople each receive $250 per week plus 10 percent of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $250 plus 10 percent of $5000 (=$500), or a total of ($500+$250=$750).

Develop a C program to input each salesperson's gross sales for last week and calculates and displays that salesperson's earnings. Process one salesperson's figures at a time. The output should be similar the followings:

 Enter your sales in dollars: 5000.00

Your Salary is: 750.00

Q4. if...else and switch statements

In the attached link, you will see the example used in the class for explaining the switch statement. Instead of using switch, try to rewrite the program using if or if...else statements.

Q5. Converting a flowchart to a program

Write a program in c asking user to input two integers (n and m) and print a message according the following flowchart.

1687_figure.png

Q6. Average

Write a code in C to calculate the average (AVG) of the integers entered by a user.

  • ask the user to enter the values.
  • to show the end of data entry use -1.
  • Print the average like the following example: (suppose the user has entered 2, 3, 4) The average value is 3.00.
  • Use the following formula for calculating average of n integers x1, x2,...,xn. AVG = (x1 + x2+...+xn)/n
  • The default is the user enters just positive integer numbers. (-1 is sentinel value.)

Q7. Perfect square

In mathematics, a square number, sometimes also called a perfect square, is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 9 is a square number, since it can be written as 3×3. (Text from Wikipedia)

Write a program to check if the input number (less than 1000) is the summation of two perfect square or not. For example 25 is 16+9 that both numbers 16 and 9 are perfect square. The output should be such as the following examples:

If input is 3 → the message should be: 3 is not a summation of two perfect square.

If input is 25: → the message should be: 25 is the summation of two perfect square, because 25 = SQ (3) + SQ (4).

Q8. Cruise ship cost

A cruise ship offers the following packages for 5 day / 4 night Cruise & Stay.

Package                         Rate

1. Room only                  $1000.00

2. Room plus Meals         $1000.00 + $200.00 for each person sharing the room (Maximum 3)

Discount Details (just for package 2):

-$50.00: if just one of the occupant is 17 or under

-$80.00: if at least two of the occupants are 17 or under

Write a program to ask the user the following information:

  • The package type (R: Room only and M: Room plus Meals)
  • Number of persons who share a room and their ages.

You may assume that the user input for all the numerical data is entered as integers and greater than zero. Based on this information the program should calculate and display the package cost as below:

Q9. Equivalent resistance for Series and Parallel Resistors

The following formulas are used for calculating the "equivalent resistance" in electric circuits.

In Series resistances: Req = R1 + R2 + R3 + ?

In Parallel resistances: Req = 1/(1/R1 + 1/R2 + 1/R3 + ? )

To calculate the total current (????????????) in a combinational circuit like the following figure, it is enough to use the following formula.

Itotal = V/Req, where V is source voltage.

Write a code in C programming

Asking two questions:

1. The type of resistors model (p for parallel and s for series)

2. The values of the resistors are in "ohm".

After the last resistor was entered, the user should enter "-1" to exit.

Note: there is no negative value resistor and a "0-ohm" resistor in parallel systems cause a short circuit; the equivalent resistor will be 0 and the total current will be infinity.(For series system if all of resistors are zero, a short circuit will be occurred.)

The voltage supply is a fixed value 24 volts.

Calculate the equivalent resistance and report it.

Calculate the total current and report it.

If user entered a negative value for a resistor, the program should show a message and ask the user to make it correct.

All of the elements are considered ideal.

Q10. Calculate the acceleration of a system

An Atwood Machine is a basic physics laboratory device often used to demonstrate basic principles of dynamics and acceleration. The machine typically involves a pulley, a string, and a system of masses. Keys to solving Atwood Machine problems are recognizing that the force transmitted by a string or rope, known as tension, is constant throughout the string, and choosing a consistent direction as positive. To calculate the acceleration of two masses the following formula is used.

2061_fiogure1.png

Write a code in C

Asking masses m1 and m2. (unit should be in kg)

g = 10 m/s2

Calculate the acceleration a (should be positive) and direction (m1: down or m1:up)

Show the results as below:

  • Mass m1 goes .............. down/up................ with acceleration ............ a ............... (Meter per second squared)
  • m1 and m2 are equal and they are balanced.

Attachment:- Assignment File.rar

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92475533

Have any Question?


Related Questions in C/C++

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As