C++ :: Timer With Non-return Calculations

Dec 25, 2013

My game runs in a while loop, as you can see in the code below. I need a timer, which won't stop this loop or freeze it, but it will wait, until timer is over and executes code without interfering with the while or for loop.

Code:

Code:
#include <iostream>
#include <iomanip>
#include <windows.h>
#include <ctime>
using namespace std;
char *map[25][25];

[Code] ....

View 1 Replies


ADVERTISEMENT

C++ :: Creating Timer - Count By Milliseconds And Return A True Value

Jun 19, 2013

I'm looking to create some sort of a timer. I'd like it to count by milliseconds and return a true value when it counts to a specific time. It would be used something like this:

if(alarm(1000)) {
// do some code
}

I tried using time.h, but it doesn't seem to have any millisecond commands. I need something faster than a second.

View 2 Replies View Related

C/C++ :: Calculations From Textfile?

Mar 31, 2014

I have a text file that contains values as follows:
2013 05 27 15 52 02.049824 231.401 0.022 49.738
2013 05 27 15 52 02.668822 229.814 0.019 49.738
2013 05 27 15 52 03.283705 228.528 2.599 49.726
2013 05 27 15 52 03.898469 230.140 2.576 49.751

Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? I also have to use at least one integration method. The file data contains over 50 thousand lines in the format mentioned above.

View 11 Replies View Related

C++ :: Calculations From Text Files?

Mar 31, 2014

I have a text file that contains values as follows:

2013 05 27 15 52 02.049824 231.401 0.022 49.738 2013 05 27 15 52 02.668822 229.814 0.019 49.738 2013 05 27 15 52 03.283705 228.528 2.599 49.726 2013 05 27 15 52 03.898469 230.140 2.576 49.751
Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? I also need to include at least one numerical integration technique. The file data contains over 50 thousand lines in the format mentioned above.

View 2 Replies View Related

C++ :: Calculations Are Done Correctly But Showing Zero

Nov 26, 2013

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

View 1 Replies View Related

C++ :: Calculations From Text File?

Mar 31, 2014

I have a text file that contains values as follows:

2013 05 27 15 52 02.049824 231.401 0.022 49.738
2013 05 27 15 52 02.668822 229.814 0.019 49.738
2013 05 27 15 52 03.283705 228.528 2.599 49.726
2013 05 27 15 52 03.898469 230.140 2.576 49.751

Column1=date, Column2=Month, Column3=Day, Column4=Hour, Column5=Minute, Column6=Seconds, Column7=Voltage(Vrms), Column8=Current(Irms), Column9=Frequency(Hz).

I have to develop a program that will analyse these time-sampled voltage and current measurements over 24 hours and find the total energy used, mean and peak power consumption and Energy used over each hour of the 24 hour period.

How do I go about doing this? The file data contains over 50 thousand lines in the format mentioned above.

View 5 Replies View Related

C/C++ :: Adding Calculations To BMI Calculator

Oct 8, 2014

I have to enhance my BMI program to tell whether the person is at optimal weight, under weight, or overweight and I cannot find the correct calculation. Here is the code I have so far that works for calculating the BMI.

namespace Body_Mass_Index {
public partial class BMI_HW : Form {
public BMI_HW() {
InitializeComponent();

[Code] ....

View 14 Replies View Related

C/C++ :: Overtime And Payroll Calculations

Apr 11, 2014

When you execute my code you'll notice the regular pay for the first example will calculate to $500 when it is only supposed to calculate to $400. I'm also having a problem adding up the totals of the regular pay and overtime pay to get a total payroll which is displayed in one cout statement. 95% of my code is correct, I'm just having these two issues. To make it more clear hear is my assignment:

The regular working hour for an employee is 40 hours a week. Sometimes employees work over time. When the employee works 40 or less hours, the regular pay is calculated as number of hours worked times the hourly rate. When the employee works over time i.e. beyond 40 hours then the employee's pay has two components a) regular pay (40 hours X hourly rate), and 2) overtime pay (the overtime hours beyond 40 X time and half of the hourly rate).

void compute(incomeInfo *ptrI, int count) {                                                
    for (int i = 0; i<count; i++)  
    if (ptrI->hours <= 40) {
        ptrI->regPay = ptrI->hours * ptrI->hRate;
        ptrI++;

[Code] ....

View 1 Replies View Related

C/C++ :: Menu Driven Complex Calculations

Mar 18, 2015

//complxCalc.cpp//

#include "complx.h"
using namespace std;
ifstream infile ("in.dat");
int main() {
int i = 0;
complx tempComplx;
double d = 4.5;

[Code] ....

//in.dat//
(4,4) (6,7) (2.5, 9.3) (3,8.4) (13, 26.5) (2.2, 3.4)

My plan is to make this a menu driven program, I have already got the program to give the answers but now I want it to give the user choices as well. The first step in this project is to add a menu to the program. The first menu the user sees should ask the user if the program will be taking input from a file or from the user directly via the keyboard. Regardless of option chosen, the user should then be prompted to specify whether a multiplication,subtraction or addition operation should be performed.

If the user originally chose the file input method then the program should proceed to display to the screen the results of those operations on each pair of data elements in the file and terminate. If the user chose to input via the keyboard then the user should be prompted to input the two numbers, perform the operation on those two numbers and display the results to the screen and ask the user which mathematical operation they would like to do next and continue in this manner until the user chooses to exit the program via a menu option. Fortunately the only file that needs to be edited are in.dat and complxcalc.cpp files.

View 1 Replies View Related

C++ :: Writing Calculations For Unknown Amount Of Students?

Jun 27, 2014

I need to create a program that continuously records data until the user enters '0'

The data that I read in is the student's last name, the year of the student (1-4), the major, the gpa, and the advisors name. I then need to print out how many students are in each year (1-4), the number of students each advisor has, the average gpa for each major, and so on. This is what I have, but I am stuck and think that I might be headed the wrong direction because the only thing working is the loop (not my gpa test calc).

//This program displays information pertaining to students
#include <iostream>
#include <string>
using namespace std;
int main () {
int studYear;
double average, studGpa;
string studName, studMajor, studAdvisor, complete;

[code]....

View 2 Replies View Related

C/C++ :: Using Values From Distance Array In Function To Be Used For Calculations

Mar 30, 2014

I know that the issue is around the array distance being of type double in the function get distance of type double. My question is how do i get around using the values from the distance array in the function to be used for calculations.

#include <stdio.h>/* initialization of preprocessor directives*/
#include <stdlib.h>
#include <math.h> /*preprocessor directive in order to use sqrt function*/
int calcSecondsvar(int,int,int ,double);
double getdistance(double,double,int,int,int);

[Code] ....

I forgot to mention that it keeps giving me the error cannot convert from 'double[8] to 'double' ....

View 2 Replies View Related

C/C++ :: Employee Payroll Calculations Program For A Class

Sep 30, 2013

getting output from my code when I compile, the codeblocks ide doesnt show any errors it just doesn't give me any out put when I compile?

Here is my code:

#include <iostream>
#include <string>
#include <iomanip>  
using namespace std;  
//
//CLASS DECLARATION SECTION

[code].....

View 1 Replies View Related

C :: Cache Optimizations / Make Multiplication And Calculations Faster?

Jan 30, 2014

I have a 125X125 array, each element is 55 bits. The cache line for the CPU ( Cortex A9) is 32 bits. Is there anyway to do optimizations, like loop tiling that would make multiplication and calculations faster?

View 5 Replies View Related

C++ :: Getting A File From Designated Location / Grab Value And Make Calculations

Oct 30, 2013

My project is to get a file from a designated location in my computer and not just read, but grab the values from the user and make a count, sum, and average calculation of the numbers in my code. I am using the fstream library and I am trying I did do it, I got the values and calcualated them, however I want the values to be accessed from maybe my desktop or my drive, I want to know how to manipulate my code to get a path like C:UserDesktop and maybe executed from the path input or given. I dont know if this is possible, or easy to do. ALso I did copy some of this code from my teachers examples and I dont know exatly why the variables have to be initilized at zero, and I would like to know a little more on the Bitwise right shift breaker used in line 20 something.

Here is my code below.

#include <iostream>//For avergae functionality
#include <fstream>//For the file commands, such as ifstream and the Bitwise right breakers(<< and >>).
#include <iomanip> // To control the amount of decimals in my results desired.
using namespace std;
int main () {
int aNumber=0; //Initilized at zero because of Stack Overflow:

[Code] .....

View 2 Replies View Related

C/C++ :: Create Billing System Without Using Pointers - Array Calculations

Feb 17, 2014

I am trying to create an billing system "without using pointers". This is my class assignment. In this,

1) User inputs the name
2) The system asks how many items he has purchased
3) Displays a bill number [just a random number]
4) System asks for the item names the user purchased and stores them in an array (of max 10 (ten) inputs (or items))
5) After each item the user inputs, the system asks for the price of the item (stored in an array of numbers)
6) The total bill is calculated, by adding the sum of all prices in the array

I am having terrible difficulties in coding #4 and #5. Somehow, they aren't going well together. Here's what I have:

#include<stdio.h>
#include <stdlib.h>
int main() {
char item[10][10], answer = 'y', name;
int price[10], total_item, total_price = 0, i, j, a, total_bill = 0, max_items = 10, max_char = 10;

[Code] ....

You might find a lot of unused variables

View 10 Replies View Related

Visual C++ :: Get Streamreader To Read And Calculations To Populate Textbox

Jul 27, 2013

Here what i have so far, the error in the stream

[CODE]

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String = IO.File.ReadAllText("Grades.txt")
Dim GPA As Double = 0

[Code]....

View 1 Replies View Related

C++ :: Program Compiles Successfully But Calculations Give Wrong Answer

Feb 11, 2013

I'm using MSVC++ and it builds sucessfully but somewhere something is obviously messed it. Once i try to debug it just shows weird numbers.

int k=0; //could this be the problem??? since 0 would be over writing any given value. but if i leave int k; it showsa warning and MSVC would count that as an error

#include "stdafx.h" //Header file section
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//structure declaration
struct menuitemtype

[Code] ......

View 14 Replies View Related

C++ :: Computational Calculations - Numerically Solve Quantum Harmonic Oscillator

Apr 20, 2012

My task I am trying to accomplish is write a program for C++ that numerically solves a quantum harmonic oscillator. I have a routine that I am trying to implement into this program that iterates through a matrix and finds it eigenvalues, however, I do not know how to put it all together to make it work. Code is below:

Code:
//Compiler flags and numerical constants
#include <iostream>
#include <math.h>
#define L 10.0
#define N 200
using namespace std;

[Code] ....

View 1 Replies View Related

C++ :: How To Create A Timer

Jan 24, 2014

#include<iostream.h>
#include<time.h>
#include<conio.h>

[Code].....

View 3 Replies View Related

C/C++ :: How To Reset A Timer

Apr 12, 2012

Im trying to make a reaction game. I have a grafic that comes up, and the timer starts and when i hit the grafic the timer stops. But my problem is that the Timer doesn't reset.

View 2 Replies View Related

C :: Using Timer Module In PIC Microcontroller

Feb 28, 2013

how to produce a period signal that lasts 0.100 ms that is 35% red and 65% green using a bi-colour LED and the timer module?

while(ReadTimer0() < (unsigned int)165)

Its using this: OpenTimer0(TIMER_INT_OFF & T0_SOURCE_INT & T0_16BIT & T0_PS_1_32);

So does that mean that the period signal is 165 * 32 * 4/32 = 660 = 66%? I really just need to know how to calculate the period signal to produce 35% red and 65% green..

View 1 Replies View Related

C++ :: Making A Countdown Timer?

May 17, 2013

I'm creating a game in which i.need player to.answer.my question within 10 seconds...

So I need a code for this timer... I don't want code to be paused by sleep or delay functions.. But I need that it waits.for 10 seconds.. and if user types answer in between.. it.reads it

And if player.doesn't answers it within 10 sec.. it displays a message

View 2 Replies View Related

C++ :: How To Set A Timer And Processing Continues

Apr 28, 2013

I need to set a timer but still have the program processing info. I have looked into using sleep but when using this all processing stops to my knowledge. I tried to use the settimer method but was having some issues since I am not using a dialog based interface.

View 1 Replies View Related

C# :: Timer Or Watcher For Variable?

Apr 4, 2015

I have some value in process memory (not my process). I have address of this value and want to execute function or smth else on changing this value. I think to use timers but I think they are too slow - low resolution(I read smth from 10 to 50 ms) and uses CPU too much. Can you offer me some other solution with not very much cpu usage but with checking variable value nearly 1 to 5 ms.

View 3 Replies View Related

C/C++ :: How To Create A Timer That Allows Input

May 14, 2013

I am trying to create a five second timer that allows a value to be entered in that span of time. However, if a value is not entered within the five seconds, the timer ends and a value will no longer be able to be entered. I am trying to create a math test that has a five second time limit for equations to be answered.

View 4 Replies View Related

C :: Will Return Root Statement At End Ever Return Value Other Than Value Passed To Function?

Mar 29, 2013

I'm writing some functions pertaining to binary trees. I've used recursion once before while learning quicksort but am still quite new and unfamiliar with it. And this is my first time touching a binary tree. So my question: In my addnode function, will the return root statement at the end ever return a value other than the value passed to the function?

Code:

#include <stdlib.h>
struct tnode
{
int data;
struct tnode * left;
struct tnode * right;
}

[code]....

View 4 Replies View Related







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