C/C++ :: Create Program To Calculate Flight Time And Fuel Burn Of Airplane?

Aug 8, 2014

I'm trying to create a program to calculate the flight time and fuel burn of an airplane. However when I repeated the whole calculation, it did not show any data or result like the previous calculation. In addition, the "If" statement that I used to test the "fuelRemain" doesn't work properly. I can't figure out why.

Here are the outputs [URL]

#include <iostream>
#include <fstream>
#include <string>

[Code].....

View 2 Replies


ADVERTISEMENT

C :: Program To Calculate Difference In Time?

Nov 6, 2014

i writing a code which will calculate the difference between time_in and time out. Can i use a 2 dimensional array for example

int time_in[hours][minutes]
int time_out[hours[minutes]

View 3 Replies View Related

C :: Program Which Calculate Time Difference Between Two Daytime

Jul 4, 2013

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;

[Code]...

View 4 Replies View Related

C++ :: Parabolic Shot Program - Calculate And Graph Time Vs Distance

Nov 13, 2013

It is supposed to calculate and graph time vs. distance. The problem I have is graphing, if I put too small values for Vi, which is the initial velocity, it just graphs one or two points, because t is too small. I already tried to adjust t with 'if(t<10) t=t*10; if (t>100) t=t/10;', But it seems not to solve my problem.

Other truble I have is that, as the graph is parabola, core values ​​are very close together, and when plotted, these values ​​are in the same line on the screen.

Here is my code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main() {
float x, y, hmax, t, amax, vi, v, a, b, g, ang; /*x= x coordinate, y= y coordinate, hmax= maximum height,

[Code] .....

View 6 Replies View Related

C/C++ :: Program That Assigns Passenger Seats In Airplane?

Apr 26, 2014

I am supposed to create a program that assigns passenger seats in an airplane. First I am suppose to generate an array with random X's. Then I am supposed to ask the user to pick a seat. From there I am supposed to check if the seat is already taken. My problem is when I ask them to pick a seat it generates an array of nothing but X's. Also how would I allow the program to accept the seat numbers as either uppercase or lowercase letters. for example if they want seat '3C' how would I allow them to enter the C as either a lower case or upper case.

//Oscar Lopez
#include <iostream>
#include <cmath>

[Code].....

View 2 Replies View Related

C++ :: Create A Program That Calculates Fraction Of Time?

Dec 16, 2013

I am trying to create a program that calculates fraction of time remaining when a student leaves during the middle of the semester. I have to use function files here. I am having trouble with the division in function long double tuitionfrac(int, int, int). No matter what numbers are entered, fractime gives an output of 0. I don't understand that.

long double tuitionfrac(int opening, int leaving, int semend)
{
int lefttime = semend - leaving;
cout << "Left time " << lefttime << endl; //for error checking
int tottime = semend - opening + 1;
cout << "Total time " << tottime << endl;
long double fractime = lefttime/tottime;
cout << "fractional time " << fractime << endl; //always returns as 0.
return fractime;
}

View 4 Replies View Related

C/C++ :: Program To Display Two Statistic Sheets For Airplane Races?

Mar 17, 2014

I am writing a program to display two statistic sheets for airplane races. with Acceleration being a random number 5-25. for every second it should display a stat for speed, and distance(Both planes)I am at a loss for how to call the functions separate and side by side respectively.

#include <iostream>
#include <cstdlib>
#include <iomanip>

[Code].....

View 14 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/C++ :: Create Program To Calculate A Percentage For Commission And Bonus?

Feb 11, 2014

I am using codeblocks for school and I am trying to create a program to calculate a percentage for commission and a bonus. I have tried using a decimal for percentage, int and floats with casting. Every time it I try it displays 0 or just the bonus. I even took and did a test page. My head is about to pop.

Write an algorithm that can be used to calculate the commission earned in a real estate transaction. The chart below describes the formulas used to calculate the commission.

Sales Price Commission
Less than $100,000 5% of Sales Price
$100,000 to $300,000 $5,000 + 10% of Sales Price over $100,000
More than $300,000 $25,000 + 15% of Sales Price over $300,000

// Commission and Bonuses.
#include <iostream>
#include <iomanip>

[Code].....

View 2 Replies View Related

C++ :: Create A Program That Reads Numbers And Calculate Them On A Separated Subroutine

Nov 15, 2013

I need to create a program that reads some numbers, and calculate them on a separated subroutine, and the return of this subroutine must be the sum of all the numbers. I'm getting an error but I can't figure out why =/

#include <iostream>
using namespace std;
int calc(int val, int qtd){
int sum=0;
for (int cont=0; cont<qtd; cont++)
sum=sum+val;
return sum;

[Code]...

The error that I'm getting is on the line 22.

The error message: "invalid conversion from 'int*' to 'int' [fpermissive]

View 4 Replies View Related

C++ :: Airline Reservation - Assign Seats On Each Flight

Jun 24, 2013

A small airline has just purchased a computer for its new automated reservation system. you have been asked to program a new system. Develop a program to assign seats on each flight of the airline's only plane (capacity = 10 seats) your program should display the following alternatives

Please type 1 for "SMOKING"
Please type 2 for "Non-Smoking"

if the person types 1, your program should assign a seat in the smoking section (seats 1-5). If a person types 2, your program should assign a seats in the non-smoking section (seats 6-10). your program should then print a boarding pass indicating the person's seat number and whether it is in the smoking or non-smoking section of the plane.

Use a single-subscripted array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seats is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.

Your program should never assign a seat that has already been assigned. When the smoking section is full, your program should ask a person if it is acceptable to be placed in the non-smoking area section ( and vice versa ), If yes, make the appropriate a seat assignment. If no, print the message " Next flight leaves in 3 hours! ".

View 5 Replies View Related

C Sharp :: Code To Burn And Read Files From CD ROM

Jan 9, 2013

how can i burn and read data from cd rom in c# language.???

View 5 Replies View Related

C++ :: How To Calculate Processing Time In Milliseconds

Feb 5, 2013

I want to calculate processing time in milliseconds as most of function I found give me in second. I am new user to C++, the code will be running under linux.

View 5 Replies View Related

C++ :: How To Calculate Time And Space Complexity Of Algorithm

Jan 25, 2015

define the time and space complexity of an algorithm and about what can i do when the time and space complexity are given and i should write the code corresponding to the restrictions , which i find very difficult.

View 1 Replies View Related

C/C++ :: How To Calculate NTP Timestamp To Unix Epoch Time

Mar 18, 2015

I have been trying for several months to create a simple SNTP single Client/Server based on RFC5905. Finally I manage to make it work at least I think it works correctly, but when I tried to test my code against a real NTP server (e.g. 0.se.pool.ntp.org:123) the timestamps that I am receiving need to be recalculated. I have tried several different approaches but no matter for 3 days now but no matter what I tried nothing yet.

The problem that I am having in not so much programming error is more about knowing how the NTP server operates.

How to convert the NTP timestamp to Unix epoch timestamp?

Syntax to execute the Server e.g. ./server 127.0.0.1:5000 and Client e.g. ./client 127.0.0.1:5000

Syntax to execute the Client against a real NTP server e.g. ./client 0.se.pool.ntp.org:123

Sample of working code Client:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>

[code]....

Sample of printed output when I use Server and Client.

Reference Identifier 0 LOCL
Reference Timestamp 0.0 1426637081.3564398733
Originate Timestamp 1426637087.3570333925 1426637087.3570333925
Receive Timestamp 1426637087.3570334078 1426637087.3570334003
Transmit Timestamp 1426637087.3570333925 1426637087.3570334046

Sample of printed output when I am probing a real NTP server (e.g. 0.se.pool.ntp.org:123).

Reference Identifier 0 $
Reference Timestamp 0.0 3879449560.3503094062
Originate Timestamp 1426637090.3573978972 1426637090.3573978972
Receive Timestamp 1426637090.3573992772 2722083800.781009125
Transmit Timestamp 1426637090.3573978972 2722083800.937312997

View 2 Replies View Related

C# :: Custom Media Player Time Bar - Calculate Total Size And Proportion

Dec 30, 2014

Im just wondering how would i get a formula to calculate the total size and proportion of how far the media player has been played, in proportion with the size of the sizeable form, i need an int for the:

Width of formLength of movieHow long has been played by user

I have this code so far:

//The current position played! - Within the timer.tick event arg!
string splayed = axWindowsMediaPlayer1.Ctlcontrols.currentPosition.ToString().Split('.')[0];
int iplayed = Convert.ToInt32(splayed + 1);
//The total time of the movie/audio.
string stotal = axWindowsMediaPlayer1.Ctlcontrols.currentItem.duration.ToString().Split('.')[0];
int itotal = Convert.ToInt32(splayed);

[Code] ....

I have the "AxWindowsMediaPlayer" reference installed, but i need to know how it would work...

Attached image(s)

View 14 Replies View Related

C :: Possible To Create Char String At Compile Time?

Mar 28, 2014

I would like to have a program with a 5 mb string embedded in it kind of like this:

Code:

const char *c;
c = (const char*)"BEGIN_STRING_HERE, (5 MB of arbitrary values here)";

Is it possible to generate this string at compile time? Maybe with a macro? I'm trying to avoid a source file with a 5 mb string in it.

View 3 Replies View Related

C++ :: Class Constructor To Create Date And Time?

Mar 13, 2014

I am trying to create two classes: a Date class and a Time class. The Date class has to have three private data members: day, month and year. The Time class should have two private data members:hour and minute. Each class should have two member functions: a constructor and display. I am lost and my code won't run ....

class Date {
private:
int month, day, year;
public:
Date(int m, int d, int y){
month = m;
day = d;
year = y;

[code]....

View 2 Replies View Related

C/C++ :: Sorting Airplane Seats And Their Passengers By Seat Order?

May 2, 2014

The assignment is to read in a text file of passenger names (first and last initial), seats (A1, B1, C1, D1, A2, etc.), and ticket prices. The output is specified to be a table of passengers and their seats sorted by seat order, and I also have to print the minimum and maximum ticket prices along with the owner of each ticket, along with the average of all ticket prices. My arrays are all reading in correctly, and the minimum, maximum, and average ticket prices were all easy to find. My problem is the sorting.

We were introduced to arrays a couple weeks ago and this is our first time doing any sorting. We are supposed to use a bubble sort, and while I think I gather how to use a bubble sort, it's not working in my program (so obviously I don't really know how to use it). I have tried several different things, and sometimes a few seats/names will switch around (never the way I want them to) and sometimes nothing will happen at all.

New to programming, not trying to get homework done for me, need to bubble sort airplane passengers and seats by seat order (A1, B1, C1, D1, A2, etc).

My input looks like this:

A Z A1 555.55

repeat with different initials, seats, and prices however many times the user sees fit.

I have a 1D character array for the columns(A - D), a 1D integer array for rows (1 to maximum integer), 1D float array for prices, and 2D array for name initals.

Here's the function to read in the arrays:

void read_Arrays(char seat_cols[], int seat_rows[], char name[][LAST], float price[]) {
int i, j;
for(i = 0; i < FIRST; i++) {
for(j = 0; j < LAST; j++) {
scanf(" %c", &name[i][j]);
} scanf(" %c %d %f ", &seat_cols[i], &seat_rows[i], &price[i]);
}
}

Here's the sort. The way we were shown to do it was with a 'for' loop nested within a 'do while':

{
do {
flag = 0;
for(i=0; i < ROWSIZE-1; i++) {
if(seat_rows[i] > seat_rows[i + 1]) {

[code]....

View 6 Replies View Related

C :: Create Function That Is Then Called To Calculate Powers

Nov 11, 2014

As I am taking my first steps in C, I study K&R (I guess most of you did the same, right?)

In the introductory chapter about functions (1.7) there is an example showing how to create a function that is then called to calculate powers (b**n). I simplified it to calculate only one given power, 2**5:

Code:

#include <stdio.h>
int power(int m, int n);
main() {
printf("%d", power(2,5));

[Code]....

It will then be called to make the calculation in the above string.

First things first: we already know how to use while(getchar!=EOF) to count characters (K&R chapter 1.5.2) but what if -instead- the input is a specific string? How to "read" it and how to tell my program that the string is finished? And most important: "reading" will be done in the function or in the rest of the body?

View 1 Replies View Related

C++ :: Create Function That Performs Addition Of X Days At A Time?

Jan 26, 2012

I need to create a function that performs the addition of x days at a time, taking two integer values, the first being a date (yyyymmdd format) and a number of days to add / subtract that date.

How can I perform validation if the entire amount received is a valid date and how can I add x days of that date?

View 8 Replies View Related

C++ :: Program To Calculate BMI

Oct 7, 2013

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;

[Code] ....

View 2 Replies View Related

C++ :: Program To Calculate Fractions?

Oct 24, 2013

I need to write a program that can calculate fractions.

View 2 Replies View Related

C++ :: Program That Calculate Discounts

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

C :: Time Scheduling Algorithms Program

Jan 20, 2014

I am an IT college student and this is a self-assigned project i have done in an attempt to learn programming in C AND at the same time how time scheduling of an OS works (Both done in order to prepare for upcoming semester exams) using FCFS ,SJF, RR and PS algorithms (planning on adding SRT too sometime soon). (took me 9 hours total work time including validations). What i wanna know is from more seasoned coders if i am on the right track. *cross fingers*

Code:

#include <stdio.h>
#include <stdlib.h>
#define P_Q 1000

int main(int argc, char *argv[])
{
float min_value,
}

[code]....

View 11 Replies View Related

C++ :: Program To Display AM/PM With Current Time?

Feb 14, 2013

I'm trying to display the AM/PM on my program:

Also is there a way to display the time only instead of the date? How will i change the program to display the time in standard 12 hours, instead of 24 hours?

#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t tim;
time(&tim);
cout << ctime(&tim);
}

View 1 Replies View Related







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