Thread: Where is the 411.........

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    5

    Where is the 411.........

    Hi fellow Programmers.

    Hello it is Semma I have a question. How do I represents length

    of time in minutes and outputs two numbers that represent the

    same length of time in hours and minutes in a message using the

    user's name. Here is an example of the program working:


    What is your name? Nancy

    What time in minutes would you like converted ? 750

    Nancy, 12 hours and 30 mintes correspond to 750 minutes.


    #include<iostream.h>
    #include "c:\\ftsoft\\include\\tstring.h"
    void main()

    {

    // String input
    String (G)name;
    String (L)name;
    String (M)Program;
    String (S)Identification;

    cout <<"What is your name"<<endl;
    cin >> (G)name;
    cout <<"What is your last name<<endl";
    cin >>(L)name;
    cout <<"Program of study"<<endl;
    cin >>Program;
    cout <<"Student Identification"<<endl;
    cin >> (S)Identification;
    cout "Would you like to convert time to minutes...."<<endl;
    cin >>(M)Conversion;

    // Time Conversion Calculations
    double (M)Conversion;
    Conversion Hours = t / 60;
    Conversion Mins = t % 60;

    Thank you.......(is this correct).

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    You might want to read up on allowable variable names.....

    variable names MUST start with either a letter or an underscore character _ .After that any combination of letters and numbers.Parentheses are not allowed in variable names.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    5
    Where is the 411.........
    Hi fellow Programmers.

    Hello it is Semma I have a question. How do I represents length

    of time in minutes and outputs two numbers that represent the

    same length of time in hours and minutes in a message using the

    user's name. Here is an example of the program working:


    What is your name? Nancy

    What time in minutes would you like converted ? 750

    Nancy, 12 hours and 30 mintes correspond to 750 minutes.

    #include<iostream.h>
    #include "c:\\ftsoft\\include\\tstring.h"
    void main()

    {


    // String input
    String Gname;
    String Lname;
    String MProgram;
    String SIdentification;

    cout <<"What is your name"<<endl;
    cin >> Gname;
    cout <<"What is your last name<<endl";
    cin >>Lname;
    cout <<"Program of study"<<endl;
    cin >>Program;
    cout <<"Student Identification"<<endl;
    cin >> SIdentification;
    cout "Would you like to convert time to minutes...."<<endl;
    cin >>MathematicalConversion;

    // Time Conversion Calculations
    double MathematicalConversion;
    Conversion Hours = t / 60;
    Conversion Mins = t % 60;

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    hmm obviously this is not the complete code.. but the last time i checked in c++ you need to declare your variables before you actually use them...

    cout "Would you like to convert time to minutes...."<<endl;
    cin >>MathematicalConversion;

    // Time Conversion Calculations
    double MathematicalConversion;

    and i dont think you have good variable names:

    Conversion Hours = t / 60;
    Conversion Mins = t % 60;

    unless of course Conversion is of typedef. Now if that program works then wow...

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    Originally posted by Semma

    #include<iostream.h>
    #include "c:\\ftsoft\\include\\tstring.h"
    void main()
    {
    // String input
    String Gname;
    String Lname;
    String MProgram;
    String SIdentification;

    cout <<"What is your name"<<endl;
    cin >> Gname;
    cout <<"What is your last name<<endl";
    cin >>Lname;
    cout <<"Program of study"<<endl;
    cin >>Program;
    cout <<"Student Identification"<<endl;
    cin >> SIdentification;
    What's all this stuff for? It's not used in anything you've posted.
    cout "Would you like to convert time to minutes...."<<endl;
    cin >>MathematicalConversion;
    What's this? You don't declare MathematicalConversion till later. All you really want here is a yes or no anyway. It's kind of a long variable name. What you may have meant is to enter yes or no, check for yes in an if statement, and call a function MathematicalConversion if the answer was yes. Or just do the math in the if block & cout the answer.

    // Time Conversion Calculations
    double MathematicalConversion;
    Conversion Hours = t / 60;
    Conversion Mins = t % 60;
    Conversion is not a type. int is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM