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: ";
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
I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2
Here is my code
#include <iostream> #include <cmath> using namespace std; int main() { int weight; int height; double BMI;
void input (int array[20]); //Used when user inputs the numbers. void calculate(int array[20], int *pairs); //Used to calculate the matches. void output(int *pairs); //Used to output the number of pairs.
Writing a program to calculate grades... My algorithm is long, so I only posted the part that gives me trouble. When classes== 1,2,4, or 5, the program runs fine. but it terminates when classes == 3.
if (classes==3) { do { cout<<"Enter the Letter grade for 1st class. (USE CAPS)"<<endl; cin>>grade1;
I write this code for Inverse of matrix in C language . But there is error in determinant function that say "can not convert 'float' to 'float(*)[20]' for argument '1' to 'float determinant(float(*)[20])' " ....
/* a program to calculate inverse of matrix (n*n)*/ //actually one of the way to calculate inverse of matrix is : A^(-1) = 1/|A| * C(t) that A is matrix and c(t) is taranahade A
#include <stdio.h>; #include <conio.h>; #include <string.h>; #include <stdlib.h>; const int max=20; int i , j , n , k , size=0 , row , column ; float num , det=0 , inverse_matrix[max][max] , matrix[max][max] , new_mat[max][max] , m_minor[max][max] , m_Transpose[max][max];
I'm challenged to write a program which calculates the time difference between two daytime.
compiler doesn't give an error, yet the warning: "format '%d' expects argument of type 'int *', but argument 3 has type 'int' [- Wformat]" for lines 24 and 26
However, by entering the first time the program crashes anyway. so I assume I do really need some pointer to make it read from the console can you see where my problem is?
Code:
#include <stdio.h> #include <stdlib.h> typedef struct { int Second; int Minute; int Hour; }Time;
I need to make a program to calculate the business days (Monday-Friday) in a year in C. As example:
Input 2026 Output 261
I need to consider that the year could be a leap year and that every year can start with a different day. My Problem is that i dont know how to implement the right number of business days in C. I wrote down the business days in Excel for 2010-2040. I cant see any system behind it, some years have 261 business days, some have 260 or 262 but in no order.
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>
I have been working on a program to calculate the factorial of numbers. Part of my code is copied and modified from the FAQ about validating numbers in user input.
I have encountered a problem with the for loop that I am using near the end of my code. No matter what I do, it seems that my loop only does the multiplication of b = a*(a-1) and then prints. For example, inputting 5 will result in a print of 20, but the factorial is 120.
Code: int main(void) { char buf[BUFSIZ]; char *p; long int a; long int b; long int i;
SO Im supposed to write a program that uses arrays to calculate the sum and display it. I keep getting the error that says the sum has to be initialized.
#include <iostream> using namespace std; //Function prototype int sumArray(int); const int NUM_ELEMENTS = 5;
So I have to write a program to calculate a grade letter into a number.
Letter grades are A, B, C, D, and F, possibly followed by + or –. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F–. A + increases the numeric value by 0.3, a – decreases it by 0.3. If the letter grade is illegal (such as "Z"), then your output should be "INVALID LETTER GRADE"; If the combination is illegal (such as "A+" or "F-") then your output should be "INVALID GRADE COMBINATION"
Also the code should look like this Enter your letter grade: C+ Grade value is [2.3]
// Input cout << "Enter your letter grade: "; string s; cin >> s;
I need starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score. Here's what I have so far:
//This program calculates a golfers handicap. #include <iostream> #include <string> using namespace std; int main() { int score, slope; double rating, handicap;
I am having some trouble with my class assignment. We need to write a C program that will calculate the employee salary. There are 5 employees that will need to be calculated. We are required to use a loop also.
So far this is what I have but I am receiving errors when running the program.
#include <stdio.h> int main() { int clock_num; /* employee clock number */ float gross; /* gross pay for week (wage * hours) */ float hours; /* number of hours worked per week */ float wage; /* hourly wage */ /* Prompt for input values from the screen */ printf ("This is a program to calculate gross pay.
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 */