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

  Write a program for the pololu robot

ENSE504 Introduction to Computing Write a program for the Pololu robot using the mbed compiler, where the robot moves, with each wheel running at its own constant speed

  Creating class perform computation and display results

Create a class named Numbers whose Main() method holds two integer variables. Assign values to the variables. Within the class, create two methods, Sum () and Difference (), that compute the sum of and difference between the values of the two vari..

  Software implementation of a simple three rotor enigma

Write a software implementation of a simple three rotor Enigma Machine. Please refer to the following wikipedia entries for the Enigma Machine and the Enigma Rotor details.

  Student average and the class average

The program should accept student data until the word “DONE” is entered for the student name. This data should be printed to the screen in tabular format see below). The data also should be stored in a file. One student data should be stored per line..

  Establish rules for naming namespaces for your projects

Suppose you are a member of a development team that needs to establish rules for naming namespaces for your projects. Suggest at least three rules for your projects' namespaces and usage.

  1 implement the tronomino tiling algorithm your program

1. implement the tronomino tiling algorithm. your program should take an arbitrary input positive integer k in the

  Gstring manipulation functions

Write a program that will define the followingstring manipulation functions. Each is analogous to the corresponding C++ string function.

  Write definitions of the functions to overload the operators

Write the definitions of the functions to overload the operators defined in parts a to c and write  a  test  program  that  tests  various  operations  on  the class rectangleType.

  Ansi-c program complete assignment as per written in the

complete assignment as per written in the attached

  Compute and display the new balance

Write a complete C++ program that asks for the beginning balance and the number of checks written. Compute and display the new balance and the bank's service fees for the month.

  Write pseudocode for a program

Write pseudocode for a program that prompts the user for a month and day and prints out whether it is one of the following four holidays.

  Create a ruby script that defines a function

Create a Ruby script that defines a function occurrences(list,key) that takes an array list and object key and returns the number of elements in list that are equal to key - Create a Ruby script that defines a function numSmaller(list,item) that t..

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