C/C++ :: Parking Garage Cost Calculator Based On Type Of Vehicle And Time

Nov 3, 2014

There are a few functions for this code and I am not very good with functions yet(we just learned about them last week).

//This program will calculate the cost of using a parking garage
//based on the type of vehicle and the time of parking.
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
using namespace std;
//define rates

[Code] ...

Error List:

Error1error C2100: illegal indirectionc:userscodydesktopgaragecodegaragecodesource.cpp971GarageCode
Error2error C2100: illegal indirectionc:userscodydesktopgaragecodegaragecodesource.cpp1051GarageCode
Error3error C2561: 'main' : function must return a valuec:userscodydesktopgaragecodegaragecodesource.cpp1161GarageCode

[Code] ....

View 2 Replies


ADVERTISEMENT

C++ :: Parking Garage Hours For Vehicles And Charge For Them

Oct 1, 2013

Write your question here.

Here is the code

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
#include <iomanip>

[Code] ....

My question is how would i put in the total of hours for the vehicles and the total hours for the garage for the vehicles of input... set like this

Car Hours Charge
1 1.5 2.00
2 4.0 2.50
3 24.0 10.00
Total 29.5 14.50 <---This is what i need for my code still

View 1 Replies View Related

C++ :: Federal Tax Calculator Based On User Input

Apr 17, 2014

I am doing an assignment that is to calculate the federal tax based on the users input. I am not entirely sure what it is doing, but it is definitely not what I want it to do. I commented out the loops because they seemed to have caused a problem, but there is still problems that are making the program do something else. Here is my code:

#include<iostream>
#include<string>
using namespace std;
double getData();
double taxAmount();

[Code] ....

Functions just seem like they are not my thing. It never gets to the second function to do the calculations and then return to main to display the results.

I tried changing the code to a switch(status) with a default: at the end that looped the "please try again" but for some reason, that was a fail, it created an endless loop.

View 15 Replies View Related

C++ :: How To Use Time For Time Based Movement

May 1, 2013

So I'm trying to learn how to use time for time based movement and what not. I did this only knowing the command time(&variable)

time_t timer;
int I, X;
void main() {
time(&timer);
X=timer;
while(I==5) {

[Code] ......

There's probably some other better way to do it... Obviously but for now I see it as putting current time in X.

start while
take in time constantly until I is 5
constantly asking is time>X(preset time 5 seconds ahead)
if it is
display message and add one to I

Why doesn't this display my message after 5 seconds?

View 1 Replies View Related

C++ :: Make Different Type Of Calculator Out Of Boredom

Feb 10, 2014

ive been learning from the book for 4 days and decided to make a different type of calculator out of boredom but im really having problems when i try to make it a loop? ive been scratching my head trying to work it out rewriting deleting etc but cant work it out

Code: #include <iostream>
#include <string>
using namespace std;
int main()

[Code].....

View 9 Replies View Related

C/C++ :: Comparing Time-based-responses From Two IR Sensors (Arduino)

Apr 9, 2015

I am building a project with an Arduino Uno that involves using analogue IR sensors to detect fast motion. By placing one sensor on top of the other, I want to be able to attain a variable integer from the difference in time between the responses of the sensors.

Here is my code I have so far, it is essentially for detecting motion for 1 sensor and then converting it into a MIDI note depending on how far away the motion is detected. There is also a part which compares the value from the previous time so that only above a certain amount of movement will trigger the note. I also have a variable delay to be controlled by a potentiometer.

Here is the datasheet for the sensors I'm using.

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

int currentvalA = 0; //current sensor A value
int previousvalA = 0; //previous sensor A value
int valA = 0; // value to store sensor
const int valchangeA = 40; //motion change value
int del = 0; //variable delay value

[Code] .....

View 2 Replies View Related

C++ :: Calculate Tax Of Vehicle With Polymorphism?

Dec 29, 2012

How can we calculate tax of vehicle with polymorphism? There are 3 types of vehicles: long, commercial, and private vehicles' classes. There is a common class about all vehicles.

BASE class:
1.Brand and series name (such as Toyota Corrolla, Isuzu etc.)
2.Year of production (you can term it model)
3.Engine size in dm3
4.Owner’s name (including surname) and identity
5.Plate number.

COMMERCİAL :
1.Number of seats (apart from the driver)
2.Data to indicate whether the commercial vehicle is allowed to operate at night.

LONG :
1.The tonnage (max load in tons)
2.Data to indicate whether the long vehicle is allowed to carry goods internationally.

PRİVATE:
1.The class label which can be one of {A,B,C} .

View 1 Replies View Related

C++ :: How To Make A Type Based On A Value

Jul 10, 2012

Another fun question... Is it possible to make a type, based on a value ?

What I'm looking for is way to return the smallest (sizeof) unsigned integral type that will hold a certain value.

smallest_type<14>::type // unsigned char
smallest_type<127>::type // unsigned char
smallest_type<255>::type // unsigned char
smallest_type<256>::type // unsigned short
smallest_type<64000>::type // unsigned short
smallest_type<128000>::type // unsigned long
smallest_type<5000000000>::type // unsigned long long

View 3 Replies View Related

C :: How To Insert A Node Into Linked List At Particular Location Based On Time

Feb 20, 2014

I'm trying to figure out how to insert a node into a linked list at a particular location based on a time..I have this declared outside of everything globally.

Code:

struct aTime {
char name[LENGTH];
int time;
struct aTime* next;
};

struct aTime* head = NULL; And then this function that is used to add nodes (aTime structs) to a linked list. It adds the first node fine, but not subsequent ones. I think this is because I have while p-> != NULL but it is always going to be null when the function is called since I create a new aTime struct. So I guess my question is how, after one struct has been added at the beginning, do I point to the head node and traverse the list, insert a node, and make sure everything is still linked? Do I need another temp aTime struct?

Code:

void add_time(char name[LENGTH], int seconds)
{
struct aTime *p;
p = (struct aTime *) malloc(sizeof(struct aTime));
if (head == NULL)
{
strcpy(p->name, name);
p->seconds = seconds;
}

[code]....

View 3 Replies View Related

C++ :: Template Method Based On The Type Passed Should Return A Value

Mar 8, 2014

I have a class where a method based on the type passed I should return a value.

prototype declared in the header file:

template <typename T>int getNum() const;

Code of the cpp file:

template <typename T> int class::getNum() const{
int c = 0;
for(int i=0;i<v.size();i++)
if(typeid(*(Pro*)v.at(i)) == typeid(T)) c++;
return c;
}

To invoke the method as I do:

ostream & operator << (ostream & os, Pro & obj) {
return os << obj.getNum();
}

View 4 Replies View Related

C++ :: Restart Program Every Time Type Move Of Blank Place?

Mar 5, 2013

I have to make a 8-puzzle and I got the algorithm i just dont know how to restart the program every time i type the move of the blank place in the 3x3 puzzle so i dont have to make 10000 lines to solve the puzzle

View 2 Replies View Related

C++ :: Compiler Time Checker - Invalid Application Of Size Of To Function Type

Nov 30, 2014

I have this piece of code from the book "Modern C++ Design" that checks for compile-time error. When i tried to compile it, i get the error "invalid application of size of to function type". How to make this compiler-time checker work?

Code:
template<bool> struct CompileTimeChecker{
CompileTimeChecker(...);
};
template<> struct CompileTimeChecker<false> {};

[Code] .....

View 4 Replies View Related

C++ :: Memory Cost On The Loop Of Menus?

Jun 26, 2014

I have a question on the wasting of the memory on the use of menus. What is the task: I have mainMenu, subMenu1, subMenu2, subMenu3, ... Entry from mainMenu, and chose 1(or 2, 3,..) to subMenu1. If tasks done, go back to the mainMenu.

The Codes:

void mainMenu(){
//input 1-3 by user
switch(choice) //choice is the input

[Code].....

My problem is: the call for mainMenu() in subMenus looks like a recursion, which means the memory would be reallocated again for the called maniMenu. Is that right?

If so, times of the memory space for mainMenu function are required if going back to mainMenu several times from subMenus. But what i wanna just a choice and I dont want to wast the memory.

View 4 Replies View Related

C :: Create A Program That Will Calculate A Shipping Cost?

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

C++ :: Write Program That Uses Function To Compute The Cost?

Nov 1, 2013

Write a program that uses a function to compute the cost of a pizza with given diameter and the number of toppings. Constant will be the cost per toppings and cost per square inch. It will contain a reputable structure as well.

diameter=17
number of toppings=3

//complier directives
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>

[Code].....

View 6 Replies View Related

C/C++ :: Declare And Initialize A Pointer To Variable Int Cost

Mar 2, 2014

this question would their be a different process if they asked "declare and initialize a pointer to the variable int cost[N][N]" Here's what I have so far

[#include<stdio.h>
int main() {
int a; // Step 1
int *ptr; // Step 2
a = cost; // Step 3
ptr = &a; // Step 4
return(0);

[Code] .....

View 5 Replies View Related

C/C++ :: Calculate Cost From Wholesale To Final With Percentage Markup

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

C/C++ :: Calculate Total Cost Given The Tax Values - Getting C2784 Error

Sep 3, 2014

// Purpose: calculate total cost given the tax values

#include <iostream>
#incluse <string>
using namespace std;
int main() {
double purchasePrice, stateTaxAmt, countyTaxAmt, totalCost;
//Display purchase price

[Code] ....

View 2 Replies View Related

C++ :: Equation That Determines The Lowest Possible Cost For Laying Power Line

Apr 9, 2013

I need an equation that determines the lowest possible cost for laying power line.

The variables are as follows:

1. The width of a river
2. The distance a factory is downstream from a station on the other side of the river.
3. The cost for laying line underwater.
4. The cost for laying line on land.

All these variables will be user input each use of program.

View 4 Replies View Related

C++ ::  Minimum Cost Path Visiting Half The Cells In A Grid?

Mar 11, 2013

I am trying solve this a problem: [URL] .....

In short:
1. Input is an N x N grid with a non-negative integer in each cell.
2. We can move from one cell to any of its adjacent cell in all four directions.
3. The 'cost' needed to move from one cell to another is the positive difference of their values.
4. We have to find the minimum cost such that we can visit atleast half of the cells with that cost;

I am not being able to think of any solution that runs in time O(N2) or better (N2 because of the size of N, any algorithm worse than it will not run within the time limit) for this problem.

So I need a hint on how to solve this problem optimally.

View 2 Replies View Related

C :: Calculate Cost For Production Of Open Top Cylinders - User Defined Functions

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

C++ :: Word Counter - Calculate Number Of Letters And Give Total Cost

Nov 4, 2013

I am currently working on an assignment.

#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {
char letter;
int count = 0;
double ppl = 0;
double finalCost = ppl * (count - 1);

[Code] ....

I am trying to create a word counter program that asks for the price per letter and then asks for the sentence they are writing. The app should then calculate the number of letters and give the total cost similar to:

You have 40 letters at $3.45 per letter, and your total is $138.00.

Everything compiles fine but when I run it the inputs don't work and it outputs:

You have -1 per letter, and your total cost is $-0.

View 2 Replies View Related

Visual C++ :: Calculate Total Of Monthly Costs Of Expenses And Show Annual Cost

Oct 5, 2012

The point of this is to calculate the total of the monthly costs of these 6 expenses and then to show the annual cost. However, there's just a couple of things that's giving me problems and it's the calcMonCost in my code. The error says that it is more than one instance of overload function and also that an unresolved external symbol. Everything else is fine. What does this mean?

Code:
#include <iostream>
#include <iomanip>
using namespace std;
void calcMonCost (double, double, double, double, double, double &);
void calcAnnCost (double, double, double, double, double, double &);
void getData(double &lnPymnt, double &insure, double &gas, double &oil, double &tires, double &maint);

[Code] .....

View 1 Replies View Related

C/C++ :: Round Robin Execution With Gantt Chart - Arrival Time And Burst Time

Mar 10, 2015

This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??

#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;

[Code] ....

View 2 Replies View Related

C++ :: Changing Array Of Numbers Of Type Char To Type Int?

Apr 27, 2013

I'm having some problems with changing an array of numbers of type char to type int. Every time i try to sum 2 array indexed values it returns some letter or symbol. Also, if i change the type of the array in the functions the compiler gives me an error message. I would also like to add that the problem requires that the first two arrays be char so each individual number gets assigned to a different value.

My current code is:

Code:
#include <iostream>
void input(char a[], char b[], int& size_a, int& size_b);
void convert(char a[], int size);
void reverse(char a[], int size);
void add(char a[], char b[], int c[], int size);
int main()

[Code]....

View 4 Replies View Related

C++ :: Convert Element Of Int Type Of Array To Char Type?

Dec 21, 2013

how to convert an element of int type of an array to char type?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved