Write a program that computes the total amount of money

Assignment Help Basic Computer Science
Reference no: EM13769973

1. Type the following program and save it as assign0.c. Extension should be .c and it should be lowercase. Compile the program, test it and submit it using blackboard.

/***********************************************/
/* Assignment No : 0 */
/* Name: Write your name here */
/* This program computes the sum two numbers */
/***********************************************/

#include <stdio.h>
int main()
{
/* Declare and initialize variables. */
int number1 = 4, number2 = 7, sum;
/* Calculate sum. */
sum = number1 + number2;
/* Print the sum. */
printf("The sum is %d \n", sum);
/* Exit program. */
system("pause");
return 0;
}

2. Write a program that computes the total amount of money in dollars and cents when the number of pennies (1 cent), nickels (5 cents), dimes (10 cents) and quarters (25 cents) are given. Sample execution of the program is given below.

Enter the number of pennies, nickels, dimes and quarters

1 2 4 5
You have 1 dollars and 76 cents
Pay attention to the following

(a) Name your file assign1.c
(b) Use integer division to find the number of dollars.
(c) Use mod operation (%) to find the number of cents.
(d) Test your program with the following cases. Output should match the output given after the →.

• 1 1 1 1 → You have 0 dollars and 41 cents
• 18 8 4 2 → You have 1 dollars and 48 cents
• 10 2 8 4 → You have 2 dollars and 0 cents
• 12 13 14 15 → You have 5 dollars and 92 cents

Submit your program electronicly using blackboard system

The program you submit should be your own work. Cheating will be reported to office of academic integrity. Both the copier and copiee will be held responsible.

3. Write a program that determines the roots of a quadratic equation. Given an equation of the form
ax2 + bx + c = 0

The roots of the equation can be computed using the formula

x1,2 = (-b ± √ (b 2 - 4ac))/ 2a

Your program should read the coefficients from user and display one the following messages depending on the value of roots.

• No real roots
This means b2 - 4ac < 0
• Two equal roots
This means b2 - 4ac = 0
• Two distinct roots

This means b2 - 4ac > 0

Test your program for the following cases

(a) Equation is of the form ax^2+bx+c=0
Enter a, b, c:
1 2 1
Two equal roots

(b) Equation is of the form ax^2+bx+c=0
Enter a, b, c:
1 3 1
Two distinct roots

(c) Equation is of the form ax^2+bx+c=0
Enter a, b, c:
1 1 1
No real roots

Submit your program electronically using the blackboard system

The program you submit should be your own work. Cheating will be reported to office of academic integrity. Both the copier and copiee will be held responsible.

Reference no: EM13769973

Questions Cloud

Consciously coordinated social unit : Which of the following is best defined as a consciously coordinated social unit, composed of two or more people, which functions on a relatively continuous basis to achieve a common goal or set of goals?
Concoct a list of celebrities you would like to have : Concoct a list of celebrities you would like to have attend your birthday party. Sequence sequence and confluence  confluence precision and technical reasoning
Write argumantive essay on the online shopping : Write argumantive essay as the final draft of the online shopping.
Management of business firms and other enterprises : What is forecasting and why is it so important in the management of business firms and other enterprises?
Write a program that computes the total amount of money : Write a program that computes the total amount of money in dollars and cents when the number of pennies (1 cent), nickels (5 cents), dimes (10 cents) and quarters (25 cents) are given. Sample execution of the program is given below.
Research on air pollution disasters-emissions air pollution : Choose one of the air pollution disasters described in Chapter 1 (Meuse River Valley, 1934; Donora Pennsylvania, 1948; or London, 1952), and discuss the incident in detail.
Explain the crime of assault and the crime of battery : Compare and contrast the key similarities and differences between the crime of assault and the crime of battery. Provide one (1) example of each crime to support your response
Distinction between marginal cost and incremental cost : What is the distinction between marginal cost and incremental cost and how are sunk costs treated in managerial decision-making? Why?
Describe a unforgettable childhood memory : Describe a unforgettable childhood memory.sequence precision technical reasoning confluent

Reviews

Write a Review

 

Basic Computer Science Questions & Answers

  What is an unbreakable uml diagram

What is an "unbreakable" UML diagram. I have a Java assignment, and it's asking for this requirement, but I have never seen or heard of one. A link where I can see the definition and an example would be awesome. Thanks

  How a virtual address in this machine is translated

how a virtual address in this machine is translated into a physical address, assuming that the MMU has an 8-entry fully associative TLB. Label all lines and show how many bits are in each part.

  Intro internet communication and development

From the Internet Detective, what factors should you consider when evaluating a web-based source for academic research?What characterizes the stage of internet development following Web 2.0?

  Represent 99 and -99 in 2s complement format

what are the largest(positive) and smallest (negative) integers a word can represent - Represent 99 and -99 in 2's complement format.

  Error detection-correction facility-interpreters- compilers

Compare error detection and correction facilities of interpreters and compilers. Compare static and dynamic linking. With respect to the requirements of modern applications, what are the shortcomings of 3GLs?

  Explaining reasonable values for items in risk register

Suggest reasonable values for the items in the risk register for this asset and threat, and provide justifications for your choices.

  Translate the first instruction into english

If the machine is started with its program counter containing 00, what bit pattern is in register 6 when the machine halts?

  Find out amount of access that new user needs

As a security manager for XYZ Corporation, you are asked to find out amount of access that new user needs. You contact user and ask them to help you understand what kind of access they need.

  Write a c++ program to evaluate postfix expressions

Write a C++ program to evaluate postfix expressions. Your program should take postfix expression as an input, process it with the help of stack and display the result after performing required calculations.

  We will compare the performance of a vector processor

In this problem, we will compare the performance of a vector processor with a hybrid system that contains a scalar processor and a GPU-based coprocessor.

  Write a class encapsulating the concept of a course

Write a class encapsulating the concept of a course, assuming a course has the following attributes; a doce (for instance, CS1), a description, and number of credits (for instance, 3.) Include a constructor, the accessors and mutators, and methods..

  Input controls

Explain the function of input controls.Identify four (4) types of input control and explain the function of each.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd