C++ :: How To Implement Discounts - Calculate Shipping / Handling
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
ADVERTISEMENT
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
Nov 8, 2013
So my midterm exam for programming is done. My program didn't run. Tried rewriting it once I got home. I am still getting an error that the program could not be run. Also, we weren't allowed to use the internet. So I didn't know how to calculate for the discounted rate.
I am using Microsoft Visual Studio 2010.
Given problem:
ABC Hotel offers 5-10% discounts depending on how much money has the user spent. If item purchase is lesser than 1000php (1USD is 43.19PHP) 5% discount is availed. Greater than 1000php then 10% discount is availed. Total price and discounted price should be displayed.
#include<iostream>
using namespace std;
main() {
float a,b,c,d,e,f,g,h,i,j,total,discounted_price;
cout<<"Please input price of first 1st item: ";
[Code] .....
View 1 Replies
View Related
Aug 11, 2014
I am starting to use contiki and learn c programming for my summer internship. I have to calculate the mean of the ongoing process of refrigerator power. I made the code like this
Code:
#include <stdlib.h>
#include <stdio.h>
#include <homadeus/processes/fridge_process.h>
#include <homadeus/devices/78M6610.h>
#include <homadeus/utils/utils.h>
float global_variable;
int current_state = 0; //down =0, up =1
[Code]....
How it gets the value of power is handled already. Every one second, it will display the power consumed (get_instant_power()). I don't know how to start and end the sample numbre. If I start by 1 then how should it be until? Also, is it possible if I store the power in array to accumulate?
View 1 Replies
View Related
Dec 15, 2014
How to incorporate exception handling code into my existing calcMortgage code. While I was researching exception handling, I thought "what would happen with my current code if someone input the principal with a comma in it?". Typically people write two hundred thousand like so.... 200,000. While experimenting with my original code, I remembered reading in my research that someone had done their calcMortgage with the output prompt "DO NOT USE COMMAS". So, when checking to see if my code would run, I did not use commas.
Well, guess what...using a comma in the principal causes an error with a negative numerical output. lol PERFECT!!!! Obviously, the easy thing to do would be to put output instructions in the code telling the user NOT to use commas, but the assignment requires me to use exception handling. The code itself works, but the calculation produces a negative monthly payment.
How would I insert exception handling code into my current code to correct this problem??
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
struct calcMortgage {
double Principal, numYears, IntRate, monthlyPayments;};
int main(){
[Code]...
would I use a try or a throw??
View 14 Replies
View Related
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
View Related
Nov 10, 2013
I am trying to calculate a discount based on amount bought. Why this doesn't work?
if (concreteAmount<=500)
concreteDiscount=.02;
else if (concreteAmount>500 && concreteAmount<9001)
concreteDiscount=.04;
[Code] .....
View 2 Replies
View Related
Jun 23, 2014
it will not run and im not sure why. I have a couple of errors, but I'm not sure why.
Here is my code.
//Reads input from user to determine different discounts by number of units sold
#include <iostream>
#include <string>
using namespace std;
int main() {
//Declaration and Initialization of variables
int quantity;
double discount,price = 99.00,totalCost;
[Code] ....
View 1 Replies
View Related
Mar 27, 2014
I need to insert my thesaurus words .txt to my c program applying BST. But I am not sure how.
Here are my file: awwwwwwww.txtthes.c
View 1 Replies
View Related
Mar 6, 2015
I am accepting the word from user and arranging it in ascending order like in dictionary in a file . I am doing this by comparing the user entered word from existing word in the file . All the word which is smaller then user entered word is copied to another file "temp.txt" , then the user word is printed and then the remaining word ( which are larger) from "abc.txt" to "temp.txt" . But program close as soon as i enter the second word
Code:
#include<stdio.h>
#include<string.h>
main() {
FILE *fp,*ft ;
fp = fopen("abc.txt","r+");
ft = fopen("temp.txt","r+");
[Code]....
Both file are already created before /
View 2 Replies
View Related
Dec 29, 2013
I got this issue to tackle which consists of using an FIR LPF filter to filter a wav file using C programming.
Till now I managed to tackle the filter part following this link: Implementation of FIR Filtering in C (Part 1) | Shawn's DSP Tutorials (I have my own filter co-efficients which have been produced using FDAtool on MATLAB and some other minor changes have been applied to match my requirements)
Now, the link shown does not compensate for files having a header. I have three wav files which need to be filtered. Thus I need to first extract the data from the header .. this was done using RIFFpad. Now that I have the data
Info from RIFFpad:
fmt -
Offset=20
ID=fmt
[Code].....
I've got this hint to start with: Each audio datasample inside the wav_files can be made up of a number of bytes and these bytes arestored in the little-endian order. Inside your program you have to change this to a big-endian order.
View 8 Replies
View Related
Apr 8, 2014
I'm given a project in college to use trees(AVL tree, to be specific) and file handling(not very conversant with it). But I'm not able to relate the two.
I only know that files can be used to store data. But in what way can trees and file handling be connected? I know how to implement trees but how to store it as such in files?
View 1 Replies
View Related
Oct 25, 2014
I know how exception handling works, but how should I actually use it in action? Let's say I have something like this:
Class X
{
public:
X();
//Pre-condition: example can't be 3.
void number(int example);
[code]......
If I know that the exception can only happen at the beginning of the function, is it okay to catch it right away?
View 7 Replies
View Related
Feb 17, 2015
write a program as described below: program that reads in two integers (age, social security number). You should write functions that throw an out-of-range exception forage (no negative numbers)SSN (must be a 9-digit integer) My code is written below:
#include "std_lib_facilities_4.h"
int main(){
int age = 0;
int ssn = 0;
[Code].....
View 8 Replies
View Related
Apr 12, 2013
I have a MFC app developed in VS 6.0
User can open multiple dialogs in this app. Is there a way of keeping track of how many dialogs are open at a given time?
Also, is there a way of getting the handle to each dialog from a central location?
Because the dialogs are opened from different parts of the app, i.e., different files its hard to keep track of all dialogs.
View 1 Replies
View Related
May 18, 2012
following code because i want to handle multiple connection and want to implement in my project
Code:
int newsockfd, pid;
socklen_t clilen;
struct sockaddr_in cli_addr;
[Code]...
My Questions
1. What these lines is doing
Code:
newsockfd = accept(m_sockfd, (struct sockaddr*) &cli_addr, &clilen);
Code:
close(m_sockfd);
Code:
close(newsockfd);
2. And why there is no create(), connect(), read(), write() methods for client
View 1 Replies
View Related
Feb 12, 2015
It is advisable not to throw the exception from destructor. Because if exception happens stack unwinding happens. suppose the destructor again throws the exception then on part of first exception again one exception is thrown and exceptions can not be handled at same time. This is what i read from stack over flow.
View 10 Replies
View Related
Jun 9, 2012
I'm out of track how to realize one point in exercise condition wording :
Give the OutOfBoundsException class a constructor with an int as argument that indicates the erroneous array index and store it in a data member.
How should I change the code below .
Code:
//array.h
#ifndef Array_H
#define Array_H
#include "point.h"
#include <string>
using namespace std;
class Array {
private:
Point* m_data; // Dynamic Array of Point pointers
[code]....
View 5 Replies
View Related
May 20, 2013
I'm trying to learn how to implement vectorization. Lets say I have this an array like this.
Code: int Array[10] = { 3,4,5,3,4,5,6,7,8,9};
If I traverse through the array and preform some simple calculation like adding numbers, how would I go about vectorizing this feat? For example if I want to add numbers, .
An example, add element at index 5,6,7 to element with index 1.
Code:
0 1 2 3 4 5 6 7 8 9 --- index
3,4,5,2,8,2,3,5,1,2 --- ints
View 6 Replies
View Related
Nov 15, 2013
I have a date class and i overloaded operator >> to accept input in dd/mm/yyyy format. if i enter the wrong date format my program will crash. How do i do exception handling for this? How should i do the try part? and for catch, I'll just catch a date class variable?
Code:
void operator >> (istream &is, clsDate &date) {
string inputDate;
is >> inputDate;
int mm = stringToNumber(inputDate.substr(3,2)); // read 2 characters from character number 3 start
int dd = stringToNumber(inputDate.substr(0,2)); // read 2 characters from character number 0 start
int yy = stringToNumber(inputDate.substr(6,4)); // read 4 characters from character number 6 start
[Code] .....
View 2 Replies
View Related
Apr 4, 2014
Here is my code. I am combining two words and sorting the merge word in alphbetical order. The compiler giving me warning error
Program:12:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat] Program:14:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat]
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
[Code].....
View 3 Replies
View Related
Jul 9, 2013
I'ma firmware writing, and usually use only C language (not my decision, unfortunately!).In many application we've only a text display (2 rows 16 columns ascii char, or 4x20 or something else). But the question can be used also for semi graphics panel and so on.
I'm looking for an example / library / sourcecode to handling all the pages in the project. When the program start you've a 1st page (wth info abt release, hallo screen and so on), then with a arrows buttons you can navigate throught many pages. Some of these can be called by SW (or HW) events. (Button, alarm, end of job ...) In abt 20 year of experience3 I?ve seen many type of different code.
View 1 Replies
View Related
Feb 1, 2014
I have a bunch of numbers in an array, lets say 1,2,3,4,5,6,etc... and assign these to different threads.
processor 0: arraypart = 1,2
processor 1: arraypart = 3,4
etc...
Each processor is going to delete some of the assigned numbers.Is there a 'standard' technique for merging the arrayparts at the end of the parallel section (in pthreads)? If there are a neater way of doing this with lists Im also interested in that.
Example: After parallel section array is 1,3,6,etc
View 3 Replies
View Related
May 17, 2014
This is what I have at the moment which works as I would like but wondering if there is a better way of handling? Currently just making sure I know linked-lists well enough.
Code:
void push_to_end( node_t * headRef, int val ) {
node_t * tail = headRef;
node_t * new_node = malloc( sizeof ( node_t ));
while( headRef != NULL ) {
[Code].....
View 12 Replies
View Related
Mar 6, 2015
what order a CPU would process the following arithmetic problem: 5 - (-9) = 14? Would the CPU recognize that the 'minus a minus' combination simply represents 5 + 9, and proceed with that addition, or would the CPU have to first calculate the 2's complement of -9, and then proceed to take the 2's complement of that first result in order to complete the calculation of the addition of the 'double negative'?
View 2 Replies
View Related
Apr 10, 2013
I'm fairly new to C++ programming. I wanted to accept a datatype as an input. I've seen something similar while working with the <queue> library.
When defining a new object of queue
For example:
queue<int> Queue;
How is <int> handled ??
View 1 Replies
View Related