Write a program to convert the time from 24-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore your program must contain at least the following function : a function to convert the time from 24-hour notation to 12-h notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results.
I have a vector<string> of times that I want to convert to vector<double>. The time string is in the form 00:00.000. Is there a STL or something like it algorithm or function to do this, otherwise what would be the best way to do this with a function.
This program is suppose to store input from a user (example 14 15 27) and output it three times. Once to confirm the input using the get function to recall the data, once to look like military time (14:15:27), and once to look like slandered time (2:15:27 p.m.).
The program runs, but this is what I'm getting:
I'm thinking its because I'm using the same integers to store two sets of data. I tried to create different integers for every set of data it didn't seem to fix the problem. The fact that the program is running makes trying to figure out where the problem quite confusing to say the least.
Code: #include <iostream> using namespace std; class time { private: int hr, min, sec;
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;
From my tests I found the problem to be somewhere in the Mantissa part that converts it to binary.
bool xsDLL GetHexFromSF_IEEE754( void* to, Text from, ui08 tSize ) { from.UpperCase(); int db = 0, dB = 0, dBEnd = tSize, dBLast = ( tSize - 1u ), dbEnd = dBEnd * 8; ui08 *data = reinterpret_cast< ui08* >( to ); for ( ; dB >= 0; --dB ) data[ dB ] = 0u;
[Code] ....
Adjustments made, still having problems though. After finding a more useful resource [URL] ..... I got the function looking more like it should but am still having problems...
according to here [URL] .... ô in decimal is 147 and print ô using alt 147
and here [URL] .... ô in dec is 244 but prints ⌠ using alt 244
put on console
char c = ô; cout << (int)c << endl;
prints -109 and print m using alt -109
I am using alt to test char output. Why I'm getting a negative value? Which of the tables are correct? I have string of char that I want to print in hex. I get a hex string but the hex value don't correspond to any of the two tables on the websites because the console converts special char to negative values.
I am having problems with converting a CString to an int and than doing checks on the int to see if it is in a particualr range.Below is what I am doing.
CString numstr = "28" int num = atoi(numstr); BOOL valid = TRUE; if(num < -32,768 { valid = FALSE; }
For some reason when running the above code the if statement is executed but it should not be becasue 28 is not less than -32,768. Why this is happening, I am not seeing the reason for this at all!! The num variable is being assigned the correct value.
I have to convert my netpay which is a float to a string So if I input a value of say, 356.26 it should output "the sum of three hundred fifty-six and 26/100 dollars" . My program function works for the sum of three hundred but after that it spits out garbage.
i m trying to write a code that would convert a each letter from a text to their decimal images . while i was able to write the part of entering the text , i cant do the converting part , i searched all day on the internet and found nothing.
I am trying to read into a file that has something like
I have 5 apples and 9 bananas. Sam has 8 apples and 6 bananas.
and I need to replace the numbers with words. For example I need to change the "5" to five and so on. The problem is that im not sure how to access and then replace just the numbers.
How will I add the existing content of the text file to the newly inputed date(hoursworked & minsWorked) to compute the total number of hours works. I'm just a beginner in using Visual basic C++.
I'm trying to find a way to accuratley convert a double in the form of a bank account number stored in a file into a string representing the number returned by a file.
BASICALLY, I have to convert netpay (float to string). Theoretically if I have 666.66, my program here should output the sum of "six hundred sixty-six and 66/100 dollars".
i think i need to convert a double to a string, we are working in visual studio doing a program. when i run the calculator i'm not getting the answer i need instead its giving me 0.0 when it should be reading 0.5, here is the code i'm using
{int width; int height; int area; double gop; String ^strWidth; String ^strHeight; String ^strArea; String ^strGop; strWidth=width1->Text;
Sandy is of class Person, who converts to Muslim and takes on a new name Fatima, and has all the attributes of Sandy, with new Muslim attributes (e.g. religion == Islam, etc..). At this point, Sandy can be deleted, and Fatima, now of class Muslim will play Sandy's role henceforth. The problem is that due to her new address, all the people who knew Sandy does not know Fatima. Manually changing Sandy's address to Fatima's address for all those people who knew Sandy is clearly not an acceptable method. I looked through all the design patterns and cannot find one to solve this problem. how to improve the design? Here's my simplified code showing the problem:
#include <iostream> #include <string> #include <typeinfo> class Person { std::string name; Person* bestFriend;
[Code]...
Output:
sandy = 0x32658, 6Person Mary's best friend is Sandy. fatima = 0x23fec0, 6Muslim Mary's best friend is Sandy.
Of course, we want to have: Mary's best friend is Fatima,. with mary->getBestFriend()->getReligion() == Islam, etc... How to redesign the whole thing so that this is automated (assume there are thousands of people who know her)?
Creating array in main and then calling a sorting function from sorting class.
In main:
const size_t SIZE = 100; int *array = new int [SIZE]; //fill array with ints, not shown here quickSort(array, SIZE); //calling the sorting function in the sorting class
In the sorting class, quickSort is declared as such:
void quickSort(int arr[], int num);
Everything works great.
Version 2 (issues)
Instead of creating the array in main, I have set up a class for the array, MyArrayClass, where I create an object containing the array of ints. So far so good. The issues come when I write a member function to call quickSort. Even though my MyArrayClass object contains an array of ints, the code calling for quickSort() won't compile as the data type isn't ints but MyArrayClass (which in turn holds ints though). The compiler (using VS 2013 btw) complains that quickSort can’t convert the first argument from 'const MyArrayClass' to 'int[]'.
How do I cast my class object array of ints as an int[] in order to be able to call the quickSort function? Or should I solve this issue in some other way? I tried altering the sorting function to accept the object as it is, but that only created an avalanche of new errors, so thinking that converting/casting the object array --> int[] might be easier...
I am tying to convert an int to a char. Below is an example of the code that I have but I am getting an error('=':left operand must be l-value). I am not seeing a problem with the code.
int num = 5; char temp[2]; char final[2]; itoa(num, temp, 10); m_pRes->final = temp;
Ok so I'm in a programming 1 class working with c++. I have the following assignment:
Write a C++ program that: asks for and accepts the Percentage earned with as a double (i.e. 75.45) rounds it to an integer (>= .5 rounds up, <.5 rounds down.) prints the original Percentage and the corresponding Grade and Points exactly as shown below. prints an error message for any input that is less than 0 or greater than 100.
For example, if user enters 89.4, the program prints out: Percentage: 89.4% Grade: B Points: 3.00 You must use an if-else statement to do this in your program. Use fixed and precision output manipulators (see Ch. 3) to display the values with the exact precision shown above.
IMPORTANT: Each if statement condition should contain only one comparison! read this again This means code that is similar to this is NOT okay: if (Percentage >= 80.00 && Percentage <90.00) This code is not acceptable because the if statement condition above has two comparisons. (Hint: If you order your if-else chain statements correctly, you will only need one comparison in each.)
I have the program working, but I'm pretty sure I'm not rounding how my professor would like it to. This is my code:
So my issue here is the rounding, and then theres the converting the double percetnage to an integer. In my next assignment I have to write the program with a switch statement.