C++ :: Program To Call Relevant Functions To Calculate Final Price
Sep 14, 2014
I want this programming to call functions choose between a customer type and call the relevent function to calculate the final price but it is not calling the functions.
#include <iostream>
using namespace std;
double amount;
double studendOrPensioner(int&choice, double &origPrice);
double OtherCustomers(int&choice,double& origPrice);
[Code]...
View 1 Replies
ADVERTISEMENT
Feb 20, 2013
Write a C program that calculates the final value of an investment made in a TSX Market Linked GIC.
Specification
The return on this type of GIC (Guaranteed Investment Certificate) is based on the initial investment, the number of years (1, 2 or 3), a minimum return rate, a maximum return rate, a participation rate, the values of the TSX (Toronto Stock Exchange) index at specified intervals during the years, and the type of averaging of these values. The final investment value can only be calculated once all the TSX values are known.
If averaging is not used the TSX rate is determined from the opening and closing values only. If averaging is used the TSX rate is determined by calculating the TSX average at 6 monthly intervals, then is based on this average relative to the opening value. The TSX rate is then multiplied by the participation rate. If this new rate is below the minimum rate, then the minimum rate is used, and if it is above the maximum rate, then the maximum rate is used. Rates are printed to 2 decimal places, and the final investment is rounded down, and formatted using commas.
Only round down for the final investment. If the TSX rate is negative do not print the line for rate adjusted for participation. Assume that the final investment is less than one million dollars. (Hint: if you need to print leading zeros in a number, use the %0m.n format: example - the format specifier %06.2f prints 4.56 as 004.56)
Example 1: See below; averaging is not used, so TSX rate = (107-100)/100 = 7%. After using a participation rate of 80%, get 5.6% (which is between min & max rates).
Example 2: See below; averaging is used over 5 values to get a rate of 68% which equals 54.4% due to participation. This is more than the max rate, so the max rate is used.
The GIC calculator must use the following layout exactly.
+------------------------------------+
| TSX MARKET LINKED GIC CALCULATOR |
+------------------------------------+
Enter initial investment : 1000.00
Enter number of years [1,2,3] : 3
Enter minimum and maximum rates [%] : 1 20
Enter participation rate [%] : 80
Enter if averaging used [1=yes,0=no]: 0
Enter open and close values : 100 107
TSX rate . . . . . . . . . . . . . . 7.00%
Rate adjusted for participation . . 5.60%
Final investment . . . . . . . . . . $ 1,056.00
+------------------------------------+
| TSX MARKET LINKED GIC CALCULATOR |
+------------------------------------+
Enter initial investment : 2000.00
Enter number of years [1,2,3] : 2
Enter minimum and maximum rates [%] : 1 20
Enter participation rate [%] : 80
Enter if averaging used [1=yes,0=no]: 1
Enter 5 TSX values : 200 190 320 430 540
TSX rate . . . . . . . . . . . . . . 68.00%
Rate adjusted for participation . . 54.40%
Maximum rate is applicable . . . . . 20.00%
Final investment . . . . . . . . . . $ 2,040.00 i wrote something like
Code:
#include <stdio.h>
int main (void)
{
int years, minimum, maximum, partrate, x, open, close, tsxvalue;
float investment, tsxrate, y, finalinvestment, maxrate, minrate;
printf("+------------------------------------+
[Code] ....
I don't know what the exact calculation should be here now to get the rest....so I'm stuck here
View 2 Replies
View Related
Aug 27, 2014
#include <stdio.h>
float total, avg, max, min;
float judge[4];
int index;
int array[4];
int main() {
total = 0.0;
max = array[0];
min = array[0];
[Code] ....
I dont understand how to make the array when it prints out only print out the final average and the final maximum score with the final minimum score but what its doing at the moment is just giving an average for each individual score taken...
Minimum and maximum scores are displaying 0.0
And it displays these things 4 times in a row i just want it to be displayed once.
View 1 Replies
View Related
Feb 22, 2015
I have been trying to calculate the bond price given a certain YTM using class method. Since the YTM and bond price are linked with each other(there is another question asking us to calculate the YTM with a given price),we put price and YTM in "private" and others variables in"public". Actually, this is the format given in my assignment.
I used "getvalue" to get the value of YTM, and used YTM in the formula of bond price calculation. However, the output of the price is infinite, while the output of price is right if I used a specific value of YTM(such as 0.05) in the formula. It means that I didn't successfully get right value of YTM.
#include <iostream>
#include <cmath>
using namespace std;
class bond{
public:
bond(){};
[Code] .....
View 1 Replies
View Related
Apr 15, 2014
Program calculates cost from wholesale to final cost with percentage markup!
#include <iostream>
using namespace std;
int calculate_retial(int,int);
int main () {
int wholesale;
int markup;
int cost;
[Code] ....
View 5 Replies
View Related
Jan 31, 2014
I have to create a program that calculates the final scores per diver, who each get five dives. I have to include the difficulty level when figuring out this score, and I need to drop the highest and lowest scores.
Now, I'm reading from a file where the values are something like:
234 :Diver number
2.3 :Difficulty
2.1 3.2 4.0 2.3 3.8 :Scores
Would I create a parallel array for the difficulty, or include it in a 2D array with the scores. Something like
score[Difficulty][individualScores]; ?
Also, would I include a findMin and findMax in a function that calculates the total, seeing as how the highest and lowest must be dropped to determine the final score?
View 11 Replies
View Related
Apr 25, 2013
SYNOPSIS : KBJ tourist agency Sdn. Bhd wants you to write an application program to calculate the total price for their customers for a package of vacation. The following table shows the price for three destinations (transportation and accommodation) offered by the agency:
Destination TransportationAccommodation
Pulau Redang Child RM15.00
Adult RM30.00RM95 per day
Pulau Perhentian Child RM20.00
Adult RM30.00 RM100 per day
Pulau Kapas Child RM10.00
Adult RM20.00 RM120 per day
This agency company will give some discount to a group of customers with is:
a.10% discount will be given for the group that has a least 5 adults.
b.25% discount will be given for the group that has more than 5 persons (adults and children)
c.30% discount will be given for the group that has at least 15 persons.
Your application program has to display the output using this following screen layout:
KBJ TOURIST CUSTOMER INFORMATION
Customer’s name: XXXXXXXXXXXXX
Number of Children:XXXXX
Number of Adult: XXXXX
Transportation: RMXXX.XX
Accommodation: RMXXX.XX
Total price: RMXXXX.XX
This is the code i got so far but it doesn't work..:(
#include <iostream.h>
int main () {
char customerName,code,A,B,C;
int childNum,adultNum;
double rate,discount,totalPrice,a,c;
[Code] .....
View 8 Replies
View Related
Feb 21, 2014
I already wrote a program that will calculate the gross pay for a set of employees.
I want modify the code by adding multiple functions.
I want to create a separate function whenever possible to break up the program.
For example, I would like have a function for obtaining the hours from the user, another function for calculating overtime hours, another for calculating gross pay and another function for producing the output.
#include <stdio.h>
#include <stdlib.h>
#define STD_HOURS 40.0
#define OT hour>STD_HOURS
#define SIZE 5
int main() {
int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */
[code]....
View 2 Replies
View Related
Sep 15, 2014
I am trying to code a program that takes in user inputted data about percentages and using it to later on calculate a final grade. 4 percents are inputted, for Assignments, Midterm1, Midterm2, and Finals. If the percents dont add up to 1 (i tell the user to enter the decimal value) I set up and if statement to catch it and end the program. Except that if i type in
Assignments = .3
Midterm1 = .3
Midterm2 = .3
Finals = .1
the program doesn't recognize that they add up to 1. Heres the relevant portion of my code [URL] ....
Here's some examples of how it works [URL] ....
And heres what i dont understand [URL] ....
Why is it saying .3 + .3 + .3 + .1 != 1 when .1 + .3 + .3 + .3 == 1?
View 1 Replies
View Related
Jun 9, 2014
This program in not completed. I am creating a large program in order to calculate a company's weekly payroll. For now I am filling in the separate functions piece by piece before the rest of the program is completed.
Right now I am trying to use separate functions to call other functions. I need to ask the user for the file name and then open the file. I am no longer getting any compiler errors however when I run the program all it displays is "Welcome."
So it's not actually calling the NameTheFile function and the OpenTheFile function. It just says "Welcome" and then closes down. Why is it doing this?
/*Program to determine company's weekly payroll*/
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void NametheFile() {
ifstream inputFile;
[Code] ....
View 1 Replies
View Related
Jan 28, 2015
I have a program that is reading six characters from a text file, swapping every other character(ABCD would read BADC), and then adjusting their value based on a user's adjusted value input. If the adjusted value is 5 then letter A becomes F.
The final output line should print the initial six characters followed by the final six characters after the swap and encrypt adjustment.
I can only manage to print the final characters. Am I far off thinking I need to use pointers to point to the original character values?
One more thing: instructor wants us to complete this project as simply as possible meaning without the use of arrays, loops, switch statements, etc.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
//declarations
char c1,
[Code] ....
View 4 Replies
View Related
Apr 7, 2013
I'm writing a program to calculate a final grade by adding 4 numbers minus the lowest grade and dividing by 3. My knowledge in c is not extensive I thought that a simple assigment operator would do the job but I'm getting a strange large numbers in the execution.
Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int eg, g1, g2, g3, g4, fg, s1, s2, sg;
[Code] ....
View 4 Replies
View Related
Oct 24, 2013
I'm writing a function that is to return the price of something.. What would be the most appropriate return type for this? Like in Java it would be a double...
View 6 Replies
View Related
Jan 28, 2013
An instructor needs you to write a program that will compute the final average grades in her class. There are 5 students in the class. Each student must take 2 exams and 4 quizzes as part of their final grade. The weight of each toward the final grade is as follows:
Exam 1 – 30%
Exam 2 – 30% Quiz 1 – 10%
Quiz 2 – 10%
Quiz 3 – 10%
Quiz 4 – 10%
You must use arrays to store each students 3 digit ID number, exam scores and quiz scores. A multi-dimensional array is mandatory. Request from the user the information needed then output all of the information as well as the final average grade for each student.
View 1 Replies
View Related
Apr 23, 2014
I am writing a program where f is the frequency and the x has the values as well. Now I am calculating the mean which is summation fx divided by summation f. I have the two functions working correctly but the getmean function is not working. It suppose to divide fx/f . check the code below
#include <iostream>
using namespace std;
const int SIZE=5;
class statisticalOperator{
[Code]....
View 2 Replies
View Related
Nov 21, 2014
Create a user-defined program that will compute the price per square inch of a cake using an “overloading”. The cake could be a circle or a square type. In the main function, ask for the price of a circle cake and its diameter, while for the square cake, ask for the price, its length and width. The process must be done inside the different function of each cake. (Note: two sub function for the computation of a circle and a rectangle)
Note that when I made this program something weird happen. After inserting the name, all things follow.
<code>
#include "stdafx.h"
#include <iostream>
using namespace std;
double areaRectangle(int l, int w);
double radiusCircle(int r);
[Cpde] .....
View 4 Replies
View Related
Dec 24, 2014
We had few functions which were written in Java, and we are now moving to C# .Net.
Instead of re-writing the code in .net, I want to know if there is any possibility to use those functions in .Net as is. (calling java functions).
View 1 Replies
View Related
Aug 3, 2013
i am using c language to program PIC micro controllers, i am making a multi compilation unit project in order to organize my code better.
I want to create an array of functions and be able to call it from anyplace in the code
what i have done so far gplib.c
Code:
typedef void (*out)(int8);
void OUT_A(int8 weight){output_A(weight);}
void OUT_B(int8 weight){output_B(weight);}
void OUT_C(int8 weight){output_C(weight);}
void OUT_D(int8 weight){output_D(weight);}
void OUT_E(int8 weight){output_E(weight);}
out output_port[5+1] = {OUT_A, OUT_B, OUT_C, OUT_D, OUT_E};
how to declare them in gplib.h and how to call them anywhere in the code.
View 7 Replies
View Related
May 26, 2013
Here is a working C++ program and its output that reads the names of a certain number of functions whose names are written in a disk file that provides the control parameters in a near-real time fashion. Based on this information, the program calls those functions whose names were given in this text file as parameters. The method I have used is to build a map of functions that connects the names of the functions to the actual functions. Once this map is created, then it is very easy to iterate in such a way that only those selected functions are called.
So far this is working well, and it makes the logic of the code easier because ultimately there will be a large inventory of functions (probably hundreds of functions), and this way of pre-building a map of functions avoids writing hundreds of if statements in the code. Of course, pre-building this reusable map in the background is still equivalent to writing that many if statements, but at least it makes the code very compact and much more automatic, since it is done only once.
But I now have a related question: In this case (when the selected subset of functions to call is given as incoming data as in this example), does C++ make it possible to avoid using maps of functions, by directly applying the string variable that holds the name of the function in order to call the original function immediately For instance, if a string variable s = "MyFunction", then is there a more direct way of using this string as if it were the actual function whose name is spelled exactly in that way? This would make the code even more compact.
Here is the sample test code for the map of functions, and its output:
First of all here is the text file "FileForNamesOfFunctions.TXT" that contains the part of the "data", which is the set of functions select from from the inventory and only call these:
Code:
function2
function3
function5 And here is the C++ code that uses this "data":
Code:
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
[Code] ....
View 8 Replies
View Related
Sep 27, 2014
This week we are learning to use templates, and I don't understand how to call my member functions with my template based class. I tried the standard convention of calling member functions, but I keep getting an error saying name following"::" must be a class or namespace name. I'm thinking my problem lies with my typename T, but I am unsure. Line 16 is where I am getting tripped up.
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
template<class T>
T Set
{
public:
[Code]...
View 2 Replies
View Related
Jan 17, 2013
I was trying to make a program of calculating simple intrest using functions. I don't know whats wrong with the program but it always shows a wrong output.
#include<iostream.h>
#include<conio.h>
float si(int p,int r,int t) {
return ((p*t*r)/100.0);
[Code] ....
View 4 Replies
View Related
Sep 13, 2014
I would like to make a program for calculating the total price of a game station, and a game. I made a program like this for just the price of a game in class, but I want to make one that does the game system as well.
View 7 Replies
View Related
Jul 24, 2013
This is an assignment which the purpose is to calculate an angle value in form of trigonometric functions. These are the codes that I've wrote so far.
#include <iostream>
#include <cstdlib>
using namespace std;
void menu(double &value) {
system("cls");
cout<<"*****Trigonometry Program*****"<<endl;
[Code] ....
I have completed the codes for the interface part. Before I proceed with the formula for the trigonometric functions, I would like to make sure the program is Error-free, which if there is accidental invalid input from the user, the program would the user to enter another input until it is a valid response.
The only problem I have encountered for this matter was in menu(value)
If I enter an integer, the program will proceed without error. However, If I enter a character, the program will slip into an endless loop which constantly shows this
*****Trigonometry Program*****
Please enter an angle value => Is the angle in Degree or Radian?
Type D if it is in Degree
Type R if it is in Radian
Your response=> 0 //my initial input for value
Do you want to continue?
Type Y to continue
Type any other key to stop
Your response =>
Where is the source of the problem? I'm pretty sure it's the loop, but I don't know what to do.
View 2 Replies
View Related
Apr 13, 2014
I'm writing a program that calculate the carbon footprint for car, building, and bicycle. i have three classes building, car, bicycle. class called carbonfootprint have the pure virtual and should have the formula, but i didn't find it. having a little bit hard understanding some requests. like,
• Write an abstract class CarbonFootprint with only a pure virtual getCarbonFootprint method. Have each of your classes inherit from that abstract class and implement the getCarbonFootprint method to calculate an appropriate carbon footprint for that class.
• The main() function in the given program creates objects of each of the three classes, places pointers to those objects in a vector of CarbonFootprint pointers. You need to iterate through the vector, polymorphically invoking each object’s getCarbonFootprint method.
// Test program for CarbonFootprint and implementing classes.
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector< CarbonFootprint* > list;
// add elements to list
[Code] ....
View 4 Replies
View Related
Feb 20, 2013
I have this program I wrote to calculate cost for the production of open top cylinders and how to translate it into user defined functions. Here are the user defined functions I need to use instruct() get_area() comp_area() and print_area_cost() so the program will be in 4 parts.
Code:
#include <stdio.h>
int main()
{double radius,height,cost,single,all;
float surface_area;
int count;
double pi=3.14159265;
printf("Enter the radius of the base in cm^2:
[Code] ......
View 2 Replies
View Related
Apr 17, 2013
So I know that I can call a program by system("prog.exe"), but what do I add in when I want to pass a parameter?
View 2 Replies
View Related