Visual C++ :: Calculating Shipping Charges - Amount Always Comes Up As Flat Rate Variable
May 14, 2015
I'm currently working on a program that calculates shipping charges. However I'm stuck, whenever I compile the program the total amount at the end always comes up as my flat rate variable and not the total calculated number.
Code:
#include <iostream>
#include <iomanip>
#define FLAT_FEE 5
using namespace std;
int main() {
double num, pound, ship;
ship = FLAT_FEE;
[Code] ....
View 6 Replies
ADVERTISEMENT
Oct 8, 2013
Write a program in C++ that calculates the amount to be paid to an employee based on the hours worked and rate per hour. A user will enter hours worked and rate per hour for an employee. Your program should have a function payCheck that calculates and returns the amount to be paid. The formula for calculating the salary amount is as follows: for the first 40 hours, the rate is the given rate (the rate that a user has entered); for hours over 40, the rate is 1.5 times the given rate.
I had write my own coding, but it keeps error. it is okay. But i still don't think i could share here? Still running... I will update my coding for you alls to check for any syntax or logic error. The problem is i need to calculate if the employee work for more than 40 hours which 1.5 times.
Code:
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
using namespace std;
int main(void) {
char *empname, *test, *final_output;
[Code] .....
View 7 Replies
View Related
Nov 22, 2012
I'm fairly new to C++ and have begun working with pointers. I wish to create am array called sigmaf_point that reads data from a text file. I have managed to get that working, but when it comes to using this pointer I come across some problems. The array is created as such:
Code:
double sigma [5];
double *sigmaf_point = sigma;
void read(double *&sigmaf_point)
string s;
ifstream Dfile;
std::stringstream out;
[Code] .....
I then create a coordinate system inside the main file, as the program I am writing is about modelling the movement of atoms, which requires you to know the coordinates:
Code:
int main();
double **coords_fluid = new double*[5000];
for (int i = 0; i < n_atoms_methane; i++) {
coords_fluid[i] = new double[4];
}
Now, the problem arises when I want to calculate a new variable as so:
Code:
for (int i = 0; i <= n_atoms-1; i++) {
sf1=sigmaf_point(coords_fluid[i][3]);
}
I get the error C2064: term does not evaluate to a function taking 1 arguments, and a red line under sigmaf_point that says it must be pointer to function type. I am a bit confused about this.
View 3 Replies
View Related
Feb 25, 2015
I want define Variable that has all amount of between two integer example: 2-4
View 1 Replies
View Related
Oct 31, 2013
Client:
Code: ....
string cmd = "dir c:filequeue > ";
string outputFilePath;
outputFilePath.append(getTempPath());
outputFilePath.append(" est.txt");
cmd.append(outputFilePath);
system(cmd.c_str()); // dir c:filequeue > %temp% est.txt
string content = get_file_contents(outputFilePath.c_str());
send(s, content.c_str(), content.length(), 0); I'm executing the "dir" command to get a listing of Folders/files of one Folder. Then I read the Output of the file and send it over winsock to the Server.
Now, the Problem is, I don't know how I can handle the recv properly, cause I have to set the buffer size without knowing, how much data is actually transfered. Sometimes maybe no files are in c:filequeue, sometimes a 100k.
So I tried to make recv as a Loop:
Server:
Code: ...
while (rc != SOCKET_ERROR) {
printf("
#");
gets(buf); //please no discussion about gets, I will Change this later ;)
if (strcmp(buf, "ls") == 0){
send(connectedSocket, "LIST", 4, 0);
[Code] .....
now it works, but as the recv blocks, it will never leave the Loop, even when the Transfer is finished.What should I do?
I believe I could make unblocking sockets, but that's a bit complicated. Isn't there an easier solution, with malloc'ing the buffer or a Signal when to leave the recv Loop?
View 3 Replies
View Related
Sep 27, 2014
I started to learn programming through this site two weeks or so ago. I've got a book with exercices and so on, and one of them involves calculating e within a tolerance given by the user.
The formula for calculating e is the summation of 1+(1/i!), where i -> n.
So, here's the code and I'll explain the problem below:
Code:
#include <stdio.h>
int main()
{
float error;
float terme;
float sumatori = 0;
int cicle_euler = 1;
int factorial;
[Code]...
For some reason, when I set factorial to cicle_factorial, factorial remains 0, which I find puzzling; the program always halts when 1 + sumatori is 2.0 no matter what error is.
This must be a common problem and I suspect it has to do with some distinction between variables inside a loop and variables outside it, but as I lack technical vocabulary I can't seem to find anything on Google.
View 10 Replies
View Related
Feb 25, 2015
I'm trying to make a program that allows the user to input an arbitrary amount of numbers and finding the largest of all the inputs but I keep having problems with the output.
javascript:tx('
#include <iostream>
using namespace std;
//******************************************
//CLASS COMPARATOR
//******************************************
class comparator {
public:
comparator();
[Code] .....
And regardless of what numbers I enter, I always get the output of 10. Also I got the EOF idea from my textbook so if there is a better way of doing this I'd like to hear it. I don't know any clear ways that looks nice to end the while loop when the user doesn't have any more numbers to enter.
View 3 Replies
View Related
Dec 6, 2013
Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered:
-Number of Days spent in a Hospital
-The daily rate
-Charges for the hospital services(lab test, etc)
-Hospital medication charges
If the the patient was an out-patient the following data should be entered:
-Charges for Hospital services(lab test, etc)
-Hospital medication charges
The program should use two functions to calculate the total charges. One of the functions should accept arguments for the in patient data, while the other function accepts arguments for out-patient data. Both functions should return the total charges.
I dont know why but the result always gives me 0??? This is what I have.
#include<iostream>
using namespace std;
double in_patient(int Numdays, double dailyRate, double Charge_hospServices, double HospMed_Charge);
double out_patient(double Outcharge_Service, double OuthospMed_Charge);
int main() {
double dailyRate, Charge_hospServices,HospMed_Charge,Outcharge_Service,OuthospMed_Charge;
[Code] .....
View 4 Replies
View Related
Feb 16, 2015
So im trying to create a program that will calculate a shipping cost. I'm stuck on trying to calculate the actual milage and cost. Example being 1400 miles for a 2lb package would be $2 for every 500miles. so it would cost $6. But Im having trouble getting the program to round up the 1400 to 1500 so it charges the correct amount.
I know there would have to be a way to do this without programming all the conditions.
Also the course has not reached loops yet.
Code:
// This program will calculate the shipping charges.// The shipping rates are based on per 500 miles shipped.
// They are not pro-rated, i.e., 600 miles is the same rate as 900 miles or 1000 miles.
#include <stdio.h>
#include <stdlib.h>
[Code]......
View 1 Replies
View Related
Oct 3, 2013
How to implement the discounts and the shipping and handling
The store sells chocolates:
•Milk Chocolate @ $8.50 per pound
•Dark European Chocolate @ $9.75 per pound
•White Chocolate @ $10.50 per pound
•European Truffles @ $12.50 per pound
The store allows a customer discount based on:
1.$20.00 to $39.99 10% off
2.$40.00 to $59.9915% off
3.$60.00 to $79.9920% off
4.$80.00 and over25% off
Shipping & Handling is 10% of the net total (gross – discount).
Total Owed is Net Total plus Shipping and Handling)
You are using the switch to calculate the quantity discount. Since the switch does not allow a range, you have to set a “code” for the quantity range to use in the Switch such as and integer code 1, 2, 3, or 4 or maybe a char ‘a’, ‘b’, ‘c’ or ‘d’.
#include <iostream>
#include <conio.h>
using namespace std;
int main () {
int choice; // Hold a menu of choice
int pounds; // Hold the number of pounds
double charges; // Hold the price range
float discount; //Hold discount range
[Code] .....
View 3 Replies
View Related
Apr 23, 2014
I'm having issues with drawing a flat style dropdown menu in XP.
Here is the custom dropdown menu element:
public class FlattenCombo : ComboBox {
private Brush BorderBrush = new SolidBrush(SystemColors.WindowFrame);
private Brush ArrowBrush = new SolidBrush(SystemColors.ControlText);
private Brush DropButtonBrush = new SolidBrush(SystemColors.Control);
public Color HighlightColor { get; set; }
[Code] ....
Here is what it looks like in XP:
And here's what it should look like (this is how it's rendered in Windows Vista/7):
View 3 Replies
View Related
Jul 23, 2012
I have a question about how to hook HW interrupt in flat memory mode...
@ about my application...
- application is created by combining Watcom C and DOS32/A.
- application is written for running on DOS mode( not on OS mode )
- with DOS32/A now I can access >1M memory and allocate large memory to use...(running in flat memory mode !!!)
@ current issue...
- I want to write an ISR(interrupt service routine) for one PCI card. Thus I need to "hook" the HW interrupt.
- Ex. the PCI card's interrupt line = 0xE in DOS. That means this device will issue interrupt via 8259's IRQ 14.
But I did not how to achieve my goal to hook this interrupt in flat mode ?
@ resource I found...
- in watcom C's library, there is one sample using _dos_getvect, _dos_setvect, and _chain_intr to hook INT 0x1C...
I tested this code and found OK. But when I apply it to my case: INT76 ( where IRQ 14 is "INT 0x76" <- (14-8) + 0x70 )
then nothing happened...
* I checked HW interrupt is generated but my own ISR did not invoked...
Do I lose something ? or are there any functions I can use to achieve my goal ?
View 2 Replies
View Related
Mar 19, 2014
I have a code that calculates the number of days between dates. It considers leap years and different days among months. The problem I have is when i debug the code nothing comes out.
Here is the code.
#include<iostream>
#include<fstream>
using namespace std;
bool wheep();
int daysinmonth();
bool wheep(int yr) {
if (yr % 400 == 0)
[Code] ....
this is the file its reading
1 7 9 1 10 9
View 3 Replies
View Related
Jun 7, 2013
I am making this program for a class and it works fine except for the daily interest rate for the checking account is off. The daily interest for the savings computes perfectly. The monthly interest rate for savings is 6% and for checking 3%.
Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <string>
using namespace std;
const int DAYS_PER_MONTH = 30;
[Code] ....
View 1 Replies
View Related
Apr 11, 2012
I use ffmpeg codes in my C++ app and would like to control the bit_rate parameter for VIDEO there. I tried to change its value in work (via ost->st->codec->bit_rate = 150000), but ffmpeg did not wish to change it.
I tried to make re-init of the codec:
Code:
....
ost->st->codec->bit_rate = 150000;
AVCodecContext* newContext = avcodec_alloc_context3(ost->enc);
avcodec_copy_context(newContext, ost->st->codec);
avcodec_close(ost->st->codec);
av_free(ost->st->codec);
ost->st->codec = newContext;
avcodec_open2(ost->st->codec, ost->enc, &ost->opts);
the program hanged after that codes.
View 2 Replies
View Related
Feb 6, 2015
i want to write a server and a client as below:
The server(and not the clients) will connect to the clients and just send a message. The idea is to be able to connect at each client a different time.
e.g
every 10mins connect at client 1
every 2mins connect at client 2
every 1hour connect at client 3
and so on...
So how to implement this ? Should i create a new child process for each connection and what about the timing ? A pseudo code also will work.
View 4 Replies
View Related
Aug 5, 2013
The question involves me writing a program using a overloaded function to calculate the Weekly rate of employees but they get paid hourly and weekly. I get this error but do not know why,
#include <iostream>
using namespace std;
int calcWeeklyPay(int paidWeekly, int annualSalaryWeekly)
//Returns the Weekly salary of weekly paid Employees
int calcWeeklyPay(int paidHourly, int annualSalaryHourly)
//Returns the Weekly salary of Hourly paid Employees
[Code]...
View 3 Replies
View Related
Apr 7, 2014
I have a problem requiring me to :
enter loan amount:
Enter interest rate:
Enter length of loan (years)
It wants me to input the minimum amount for the loan, and the minimum interest rate. and then output a table that has 5 loan amounts across the top in $10000 increments and 4 interest rates along the side in .25% increments.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main () {
double loan, interest, length, payment,ti;
//Enter loan price
[Code] .....
View 1 Replies
View Related
Oct 5, 2014
Write a payroll program that prompts for the number of hours an employee worked, as well as the employee’s pay rate. If the employee worked for 40 hours or less, the gross pay is calculated by multiplying the number of hours worked by the pay rate. If the number of hours worked by the employee exceeds 40 hours, the employee should receive regular pay for the first 40 hours, and receive time-and-a-half pay for the hours in excess of 40. Display the calculated gross pay on the screen.
Continue to prompt for similar data for more employees and have the gross pay of each employee displayed, until there is no more employee data to process. Then display “Good Bye”.
Your solution must be separated into three source files (Interface, Implementation, and Test)
View 3 Replies
View Related
Jun 16, 2013
Any way to create a variable using a variable in the name? So E.g. if you wanted to create an int named nr(x), and x was 1, you would get an int variable named nr1? How would you do this?
View 10 Replies
View Related
Mar 16, 2014
my goal:
have 1 program handle the UI
have that program store variables to a DLL
have the 2nd program grab the stored variables to reform some number crunching, without interfering with the UI program, and once done, have it drop the answers back into that DLL, so that the UI can grab it when it's ready.
I have made the 2 programs, + dll
What I've Achieved:
the first program accesses the dll, and loads up a variable (and stays connected to the dll, so that the Dll instance doesn't reset)
I've gotten the DLL to output the variable to make sure it's received it, and stored it to it's own global variable.
the second program connects to the dll successfully, but when it tries to retrieve the data, it returns 0's (NULL's)
My research:from what I've read, so long the dll is connected to a program, all additional programs will attach to the same instance.
how do I make the global variable in the dll be accessible to both programs? (without resorting to saving it to the HDD Idealy)
View 7 Replies
View Related
Jun 15, 2014
//I dont understand this why does "<< "
The value of global now is: " << global << "
";" is equals to nine
#include <iostream>
int subtract (int a, int b);
int global = 5;
int main(void) {
using std::cout;
int a, b;
[Code] ....
View 1 Replies
View Related
Mar 25, 2013
I have create a function which able to return value for variant of variable through a LPVOID parameter function.
Here is my coding.
Code:
void main()
{
CClassA a;
BOOL bAssign=FALSE;
CString str;
[Code].....
View 6 Replies
View Related
Dec 12, 2012
I am attaching a sample project. Basically what this project does is that I initialize a variable map<CString, bool*> m_mapTest in CView::OnInitialUpdate and then pass the variable to CDocument class. On the other hand, within the function OnSaveDocument defined in CDocument I check m_mapTest. To my surprise, the CString part of m_mapTest is correct but the bool* part of m_mapTest is wrong(I pass an array of bool in CView::OnInitialUpdate).
View 3 Replies
View Related
Oct 3, 2013
Just using Find in my source code to look for variables or whatever, works once or twice then just stops - Doesn't find anything even if it's there. If I restart VS it works again, but not for long.
View 1 Replies
View Related
Jun 24, 2014
I have one Tab called Tab4 and one main dialog box called CGrabDlg. The values of my variables are not updated when I change them.?
Here my constructor of my Tab :
Code:
CTab4::CTab4(CWnd* pParent /*=NULL*/)
: CDialogEx(CTab4::IDD, pParent )
, iFilter1(_T("F1_350"))
[Code]....
View 14 Replies
View Related