Program a simple expense calculator

Assignment Help C/C++ Programming
Reference no: EM131674053

1. Multiplication Table

Part A

1. Write a code that asks for two integers, N and R, where R must be a factor of N (Check).

2. Write a code that prints out an N * N multiplication table in one line.

3. Suppose that R stands for number of entries printed in a row. Write a code which prints out an N * N multiplication table in R columns and (N/R) rows. For example, if N = 10 and R = 5, the output should be:

10 20 30 40 50

60 70 80 90 100

Part B

1. Modify 1A such that R can be any positive integer that is not larger than N (Check).

2. Write a code which prints out an N * N multiplication table in R columns and (N/R) rows. At times when R is not a factor of N, print the remaining numbers in a new row below. For example, when N = 10 and R = 4, the output should be:

10 20 30 40

50 60 70 80

90 100   .

Produce 1 script for part 1A and 1 script for part 1B. Ignore the dot.

2. Coin Flipping Again

In homework 1, the task was to flip 4 coins randomly. Now, we would like to flip any number of coins for a certain maximum number of times.

1 Write a code which asks the user to input the number of coins that they would like to flip as well as the maximum number of repetitions.

2. Write a code which flips the user-requested number of coins and prints the outcome in sequence. For example, in the case of 7 coins:
Outcome: 1 0 0 1 1 0 1

3. Modify your code such that it flips the coins over again for the user-requested number of repetitions. For example, in the case of 3 repetitions:

Outcome: 1 0 1 0 1 0 1
Outcome: 0 0 1 0 0 1 0
Outcome: 0 1 0 1 1 1 0

4. Modify your code to immediately stop repeating if the outcome is all tails. Before ending the program, display the total number of repetitions.

Produce 1 script for the entire Question 2.

3. Car Parking

Imagine you have a car park with 10 rows and 10 spaces available in each row. Next, assume that vehicles entering the car park can be described as size 1, 2, 3 or 4. Vehicles are to fully occupy a row before starting a new one. However, when a large vehicle enters, there may not be enough space in that row to accommodate it. In such an event, skip the remaining spaces and start the new row. End when the last row is completed.

Part A

1 Write a code which fills up a single row, ensuring that the number of spaces occupied is not exceeded. The vehicle size should be generated using (rand() % 4) + 1. When the row is filled up, report the number of vehicles in the row.

2 Modify your code such that records the size of the vehicle that was unable to fit into the remaining spaces of a row. For example, when there are 3 spaces left but a vehicle of size 4 enters the car park:

Extra vehicle = 4
No space for vehicle of size 4 in this row.

Part B

1. Write a code which fills up the 10 rows with vehicles. Each row may begin from 0 spaces occupied. Assume that vehicles that do not fit into remaining spaces are "rejected".

2. Modify your code such that the extra vehicle which does not fit into the end of the row is automatically placed at the start of the new row. For example, take this scenario where the vehicles entering the car park were of size: 3, 4, 2, 2:
0 spaces occupied in row 1
3 spaces occupied in row 1
7 spaces occupied in row 1
9 spaces occupied in row 1
No space in row 1 for vehicle of size 2 2 spaces occupied in row 2

Produce 1 script for part 3A and 1 script for part 3B.

4. Expense calculator

We would like to program a simple expense calculator which gives the user an option to choose between a daily tally and a weekly tally.

Part A

1 Write a code which requests the user to key in a daily allowance limit, followed by expenses. The expenses should be keyed in one by one. Recording of expenses should be terminated by entering „0?. Return the outcome of the sum of expenses as well as the remaining allowance, including negative values. Notify the user if expenses have exceeded allowance.

Part B

1 Modify your code to begin on the first day of the week. Thus, whenever „0? is entered, return the outcome as per 4A.1 and ask the user if they would like to move on to the next day of the week. If „N?, allow the user to "restart" the current day.

2 Modify your code to begin with asking the user if they would like to use the calculator in daily mode or weekly mode. In daily mode, the calculator should just ask to do_Again after it has completed one calculation. In weekly mode, the calculator should indicate the current day of the week.

[Hint: casting daily and weekly as functions can simplify your task.]

int main (void)
{
int choice;

printf("Daily or weekly? (1 / 2): "); scanf("%d", &choice); printf("\n\n");

if (choice == 1)
DAILY( ); // void DAILY (void), no inputs or outputs if (choice == 2)
WEEKLY( ); // void WEEKLY (void)

return 0;
}

Produce 1 script for part 4A and 1 script for part 4B.

Attachment:- sample output.rar

Reference no: EM131674053

Questions Cloud

What is the probability that more than one unit has failed : What is the probability that more than one unit has failed, given that the first defective unit is the nth?
Does a parent have any constitutional or other legal rights : Does a parent have any constitutional or other legal rights that should be taken into consideration in such a case?
Show that with probability one the game will terminate : A warehouse has a stock of n items of a certain kind, r of which are defective. Two of the items are chosen at random, without replacement.
What impact executive order has in the united states : An overview of the executive order and fully explain it. What it means, what it does, and what impact it has in the united states.
Program a simple expense calculator : Write a code that asks for two integers, N and R, where R must be a factor of N (Check) - Write a code that prints out an N * N multiplication table
Find probability that each rolls the same number of sixes : Two players roll a fair die 30 times each. What is the probability that each rolls the same number of sixes?
What is the probability john makes more points than erica : Erica and John play a different game with the wheel, above. Erica scores a point each time she gets an integer 0, 2, 4, 6, or 8.
Evaluate the affordable care act : I chose to evaluate the Affordable Care Act (ACA). Randomized field experiments (RFE) are the standard for evaluations because there are very few issues.
What is the probability she wins more than half the time : A player rolls a pair of dice five times. She scores a "hit" on any throw if she gets a 6 or 7. She wins iff she scores an odd number of hits.

Reviews

len1674053

10/10/2017 7:19:04 AM

Please answers in .c files and explain work using comment lines. Question 2 and 3, please refer to the sample output attached. Write a code which prints out an N * N multiplication table in R columns and (N/R) rows. At times when R is not a factor of N, print the remaining numbers in a new row below.

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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