Waseemn 0 Light Poster

It a building that has many rooms in it. I want to be able to allocated rooms to events. eg someone wants to hold a wedding convention on 14 July from 08:00 till 18:00 and want to book a room for 2000 people. and they want tea and coffee and they want an over head projector. I want to design a system that allocates all this stuff. If your still lost as to what a conference center is then google it

Thanks for the clarification. I thought it was some sort of software. You know there is something in MS-Access called a dashboard. Well this is nothing more than a menu system. So when you said I want to develop a "Conference Centre" I had that image in mind, and wanted to inquire.

Now that I know what your objective is, I guess what I would do is start with a list of all the rooms, and all the amenities that can be provided. This list will have specific information about each room, size, capacity, ceiling hieght, doors and access points and things like that.

Also for the amenities, price per person, time to prepare, combination of other things you need, like you need cups when you serve coffee.

After this you can make a database will all these items, and a Java interface that drives the database.

Thanks for your clarification

Waseemn 0 Light Poster

Hiya Guys and Girls

I am wanting to develop a conference centre in Java.

Hi Almostanangel and All,

What is a conference centre? Pardon my ignorance.

Waseemn

Waseemn 0 Light Poster

Before going this approach, please give us in detail what you have learned in class so far (chapters, concepts, etc) and we can go from there.

Hi Alex

Thanks for your suggestion. I should have thought about it myself.

OK being a summer class, 6 weeks long, we have covered Data Types, If, while, and for statements. a bit about arrays, Classes, and methods, try and catch blocks, and now we are talking about applets.

My immediate questions as I work on a class that manipulate arrays are:

1) Access to the args array is strictly for main, or can any method in the class see it?

2) How does one pass an array of Integers or String to a method, and how does a method return an array of Integers or String to its caller?

3) An example of a Try and Catch block that would work for any exception.

By the way talking about try and catch blocks, does the error get handled in the try section or the catch section?

Thanks for any help.

Waseemn 0 Light Poster

I think an ArrayList would be beneficial to you. Read up on them, see if they sound they like would work for what you are trying to do.

Thank you for your reply. I did read up on the ArrayList, and unfortunately I am not allowed to use them due to the insistence of the instructor about not using anything not covered in class. I know where he is coming from, but again that limits us to what ever he teaches us as far as the homework assignments go. Once we finish the class we will be free to read up on other things in the not so good book provided.

Having said that, I have tried building an initialization string, but ran into data type issues. Then I thought of changing the data type of the initialization string but then I ran into index issues. Index being the number I am looking for, the one that would decribe the array size. Then I thought of splitting the initialization string into an array and then test the length of that array, and then I ran into trouble of what gets into the array.

So no matter what I do to emulate the ArrayList functionality, I end up with trouble.

I am going to have to write a whole lot of code just to emulate the dimentioning an array the same size as the user input.

Any suggestions?

Thanks a Million in advance.

Waseemn 0 Light Poster

This is what I tried-

System.out.println("Enter the number of array elements: ");

Hope it helps.

YES!!! It did help and I studied it well.

But the line above is what I need to substitute for the While iNum != -1 loop where iNUm is an input from the user, and an element in the array.

What I mean by the above is that I want the user to enter numbers, and not the array size. The array will grow as the user enters numbers, and once he enters -1, then the while loop will terminate and the array will be built by whatever the user entered.

I am also having a rough time passing array arguments to methods.

I have a method called fnSumOfElements, which should accept an array and sum up its elements. I have:

public static int fnSumOfElements(int iOriginal[])

iOriginal is the array that holds the values the user enters via the while loop above.

I call this method in this way:

else if (iChoice == 6)
{
iSum = fnSumOfElements(iOriginal);
}
But this does not seem to work, do I need [] like iSum = fnSumOfElements(iOriginal[]);

Or what is wrong with this line?

Thanks for any help.

Waseemn

Waseemn 0 Light Poster

Hello All,

OK I have a nagging question that I need to put to rest right away, or else I am going to go amok.

In Visual Basic you can declare an array without knowing its size, and then redim the array again once the array size is known.

Now I can declare an array of 1000 elements, but that is not elegant, and a total waste.

I want to do this:

If the user provides any command line arguments for main, then I can test the length of the args array and that would give me the size of my array.

But if the user does not provide any command line arguments, then I will ask the user to enter numbers using a while loop, that would go on until the user enters -1 and that would be the value that would stop the while loop. In this case, I will not know the EXACT number of entries the user will want, and thus I can not declare my array.

What would be the most appropriate and elegant solution for this?

Thanks for any help.

Waseemn 0 Light Poster

Hello All,

Now please do not laugh at me, I am trying my best here. As you all know, I am taking a Java programming introductory course at the local city college, and the instructor has mentioned that any program that contains code that he did not discuss in class will not be graded. So, now I have to format numbers in a way not using anything but what he has covered.

I am writing a program that converts a user input of a Long int number of seconds into minutes, hours and days and centuries and what have you.

I have the code working, but what I need is to make a method that would format the numbers in this fashion:

XXX,XXX,XXX,XXX

I need to find out how to Convert a Long Integer into a String. When I tried I got:

TM.java:36: long cannot be dereferenced
sNum = Num.toString();
^
1 error

Num is passed from the main method, to the method that would format the numbers, and declared as Long. sNum is declared as a String

Then I can have a loop to chop the Long Integer number into 3s and concatenate a "," as I go along.

I know there must be a Java function for that, but he has not shown us that function.

Thanks for any ideas and hints.

Waseemn 0 Light Poster

Hello All,

OK I am not sure if any of you here are also coming from the C++ forum, but I finished my C++ class, got an A, thanks to all your help, and now I am onto Java.

I am still a beginner in both Java and C++ and there is more work ahead of me to finally know enough to be able to effectively participate in these fora.

For now, the Java class requires us to write a program that will determine if a string is a palindrome or not.

My theory/approach is:

Get the string from the user.

Check if it has an even number of characters or an odd number of characters using the Mod % operand. If it has an odd number of characters then I will have what I call a pivot character where by what is on the left of this character is equal to what is on the right, and I can discard the pivot character.
Split the string into the two parts on either side of the pivot. If even, then I will have equal sides, so the division will happen without discarding any characters.

Now here comes the question(s):

Should I reverse one part and check if it is equal to the other part, this will require a For loop which might take time, and then simply say if FirstPartString Isequal(LastPartString) = TRUE then we have a palindrome.

Or

Waseemn 0 Light Poster

Hello All,

Can I use cin.getline(x,y) to read a line from a file?

What is the form of cin.getline(x,y) when used with files?

What I need to do is to output what I have written to a file to the console.

I have the file open, using ofstream, and I save names to it. Then I close the file and re-open it, using ifstream, and want to read what I have saved to it.

Thanks a lot for any suggestions.

Waseemn 0 Light Poster

Hello,

I am sorry if I am boring you, but I know of toupper() and tolower(). Is there a toProper() in C++?

Proper case is the first letter of the word is in uppercase while all other letters of the word are in lowercase.

Is there a way I can convent what the user inputs from the keyboard to "Proper" case?

This has to work on strings not characters like toupper() and tolower().

Thanks a Million.

Waseemn 0 Light Poster

>I am toying with the idea of writing the variables to a file using ofstream
You've covered file I/O and not arrays?

Yes. The book we are using is custom made for our class. Chapters are not in the order one expects, and on more than one previous occasions, the homework was modified because of that. Things do seem out of order, but... We did cover file I/O but very basic information was given. I know how to open a file, write to it, and read from it, and close it

>It's easy to say "and sort them", but how do you plan on doing that?

I know about strcmp() and I will use a set of If statements to swap the names based on the outcome of strcmp(). I know this is going to take a lot of Ifs but again, this is what I know so far.

>Maybe you should explain what you've already learned so that we don't have to guess what's allowed and what's not.

Well we have just finished chapter 5 looping. We went through all kinds of Loops. While loops, Do-While loops, and For-Next loops. We also finished If else decision making, Switch statement, logical operators, and chapter 1 and 2 were about C++ syntax and structure.

Arrays come in chapter 7, and chapter 6 is about functions. We will start chapter 6 on Saturday.

I do have previous programming experience, but not in C++.

Thanks

Wassim

Waseemn 0 Light Poster

>NOT USING ARRAYS
If you can't use arrays because they haven't been covered, you can't use any of the alternatives, because they're more advanced. Your program is likely impossible with the given restrictions, sorry.

Thanks Narue

Could you please elaborate about the more advanced alternatives you mention.

Right now, I am toying with the idea of writing the variables to a file using ofstream in the body of the For-Next loop, and then use another Lopp to read them back using ifstream and sort them.

What else can I do?

Cordially

Wassim

Waseemn 0 Light Poster

Hi All,

Please keep the laughing until the end of this request.

The new assignment that I have to work on, is a string sorter. I am to ask the user to enter how many names does he/she need to sort, should be a number between 2 and 25. Then sort these names alphabetically in the order the user chooses.

The code is written for all of the above.

My question is:

NOT USING ARRAYS, because it is not yet covered in class how can I use an elegant For-Next loop to enter all these names?

So for example:

How many names do you want to sort: user enters 5, gets stored in variable iHowManyNames

Then you have:

For (iCounter = 1; iCounter <= iHowManyNames; iCounter++)
[tab]cout << "Enter name " << iCounter << " of " << iHowManyNames << " :";
[tab]cin.getline (cName, 20);

Now obviously this will not work, because all the names will be entered into a single variable, cName and thus I will capture only the last one entered. But my question is about an elegant alternative to:

cin.getline (cName1, 20);
cin.getline (cName2, 20);
cin.getline (cName3, 20);
cin.getline (cName4, 20);
cin.getline (cName5, 20);
...
cin.getline(cName25,20);

Thanks for any idea

Wassim

Waseemn 0 Light Poster

Thank You vmanes,

Just as I suspected. I would love it if you would take a look at the code that I posted in a reply to Ancient Dragon and tell me if all looks correct. Am I using the right formats, am I too wordy in my comments stuff that would enhance my style and not the code per se.

Thanks

Waseemn 0 Light Poster

Hello vmanes

When you enter a name longer than the input allows, the cin.getline( ) sets an error condition, so no further input will be processed. If you expect to handle overly long input, you need to follow it with a

cin.clear( ); //resets error flags
cin.ignore( nn, '\n' ); //set nn to some number reasonably big,

Thanks for your reply. I was under the impression that cin.getline(cRunner1, iLength);
will read into cRunner1 iLength -1 characters and stop accepting anything beyond that. Or is it that you are telling me that what actually happens is that the input past iLenght is used for the subsequent input statements? That is if I enter a name that happens to be iLenght + 5 long the next 5 cin >> statements will be affected?

Yes I do have cin.ignore() at the next line after the } of the while loop. Do I also need a cin.clear()? Is cin.clear() an alternative to cin.ignore() that will flush the whole keyboard buffer?

Waseemn 0 Light Poster

Hi Ancient Dragon

Because that while loop has no way to stop. How does bFinish1 every get set to some value > 0 so that the loop will terminate ?

I though that by setting the value to render the While condition to be true, it will enter the loop, and within the loop I will ask the user for input thus stopping the process until the user enters something that will change the value of the while condition to false and exits the loop.

My reasoning is to check if the user enters a negative number for a time stamp. The runner has to consume some time to finish the race thus time has to be a positive quantity.

I set the condition to be while (dFinish1 <= 0) and set dFinish1 to zero. The loop will enter, the system will ask the user to input the value of dFinish1. If the user enters a negative number, or zero the input is tossed out and the system will ask again. This will go on until the value entered for dFinish1 is positive.

while (dFinish1 <= 0)
{
      cout << endl << "Reminder: finishing times must be greater than zero\n";
      cout << "Finish Time for Runner number 1: ";
      cin >> fixed >> showpoint >> setprecision(2) >> dFinish1;
      cout << "\n\n";
}

Do I have a logical error here?

Waseemn 0 Light Poster

Thank You Ancient Dragon

After I posted my reply I went back again and worked some more on my homework and I got some good results.

I still get this error:

Error 112: "RQ_SC_01.cpp", line 15 # Include file <process.h> not found.
#include <process.h> //Required for System functions.

When I add the h or without the h.

Also, now I have a working model, but it still goes through an infinite loop when the name approaches the max which is set for 25 now just for me to be able to plug in the supplied data.

The code, now looks like

//Input Section:
        //Accept the name of the runner 1.
        cout << "Name of Runner number 1: ";
        cin.getline(cRunner1, iLength);

        while (dFinish1 <= 0)
        {
                cout << endl << "Reminder: finishing times must be greater than zero\n";
                cout << "Finish Time for Runner number 1: ";
                cin >> fixed >> showpoint >> setprecision(2) >> dFinish1;
                cout << "\n\n";
        }
        
        //Ignore anything left in the keyboard buffer.
        cin.clear();

Remember const int iLength = 26; //25 Chars + 1 null terminator. and I also have

//Initalize the variables
        dFinish1 = 0.0; //The value that would enter the loop.

.

When I run this code with long names it gives me an infinite loop:

Reminder: finishing times must be greater than zero
Finish Time for Runner number 1:


Reminder: finishing times must be greater than zero
Finish …

Waseemn 0 Light Poster

Thank You Ancient Dragon

OK I changed the statements to use the strcpy function, and for the code paste as you suggested here it is.

Any line that is remarked at the edge and not in line with the code is a line that is producing a problem. The problems are listed below in order from top to bottom.

//RQ_SC_05.cpp
// RunnerQualifier_SC.cpp
// Runner's ranking according to race finish times.
// Purpose: To rank 3 runners based on finish time.
// Compiled using aCC -AA
// CS 110A SECTION 601.
// Lab homework 03.
// March 18th 2008.


#include <iostream>
#include <fstream>      //Required for File I/O Operations.
#include <iomanip>      //Required for I/O Formatting.
#include <stdlib.h>     //Required for System functions.
//#include <process>    //Required for System functions.
using namespace std;

int main(int argc, char *argv[])
{
        //File Output direction:
        ofstream outputFile;
        outputFile.open("RaceRankings.txt");

        //Constants Used:
        const int iLength = 21;   //20 Chars + 1 null terminator.

        //Variable Declaration Section:
        int iCounter;                           //Simple Integer counter.
        //3 char. variables to hold 3 user input.
        char cRunner1[iLength], cRunner2[iLength], cRunner3[iLength];
        double dFinish1, dFinish2, dFinish3;  //3 variables to hold 3 user inputs.
        char cExtraName[iLength];             //1 extra name to help in the sorting.
        double dExtraNum;                       //1 extra variable to help in the sorting.

        //Display message for user:
        cout << "Please provide Cyborg Computer with the names and "
             << "finishing times for the top 3 runners\n";
        cout << "Reminder: Names can not be longer than 20 characters"
             << " and running times must be greater than …
Waseemn 0 Light Poster

Hello All

I am writing a program, for homework, that would rank 3 runners in 1st, 2nd and 3rd places based on their finish times. I need to bubble sort the names, but it fails. Here is what I have:

//Constants Used:
 const int iLength = 21;                 //20 Chars + 1 null terminator.

//Variable Declaration Section:
//3 char. variables to hold 3 user input.
char cRunner1[iLength], cRunner2[iLength], cRunner3[iLength];
char cExtraName[iLength];               //1 extra name to help in the sorting.

Later I have:

cout << "Name of Runner number 1: ";
cin.getline(cRunner1, iLength);

and then in an If Statement that swaps the values of the finishing times I have:

cExtraName = cRunner1;
cRunner1 = cRunner2;
Runner2 = cExtraName;

I am having 2 problems:

1st problem, if I enter a name < 20 characters the system hangs, and does not go any further from the cin.getline line.

2nd problem, there seems to be a data type issue when I am swapping the names to sort them.

Thanks in advance to any help.

Waseem

Waseemn 0 Light Poster

Thanks Ancient Dragon

So I understand that getline() will limit the user's input to what I place in iLength, so iLength should be 20 or 21 to allow up to 20 characters?

In other words do I need to reserve the string null terminator's position manually or will the getline() take care of it automatically.

Thanks again.

Waseemn 0 Light Poster

Hello All,

Its me again with my quirky questions.

I am writing a program for homework and the idea is to sort the top 3 runners by their finishing time.

Also a requirement of the homework is to gather the names of the runners along side their times. The user should enter a name that would not overflow the array. I have:

const int iLength = 21; //20 Chars + 1 null terminator.

and

//3 char. variables to hold 3 user input.
char cRunner1[iLength], cRunner2[iLength], cRunner3[iLength];

and

//Accept the name of the runner.
cout << "Name of Runner number 1: ";
cin.getline(cRunner1, iLength);

I would like to put the last two lines in a While Loop to prevent the user from going over the 20 character limit, but I do not know how to figure out the length of the string entered.

Any help and clarification will be greatly appreciated.

Thanks

Waseemn 0 Light Poster

Hello All

I am trying to format my program's output to be nicer than what it is doing now, and am looking for something equivalent to the noshowpoint that would act on the fixed manipulator. Here is the story:

I have a sequential integer number that is acting as a counter on the left.

I have a random number declared as double[this is the number that I get the square root of] next.

I have the square root of number next, also declared as double.

Then comes the number squared, also declared as double, and next,

The number cubed, also declared as double, last.

I want to store the:
Sequential number and number itself looking like integers, with no trailing zeros.

Square root of number as fixed with setprecision(2)

number squared and the number cubed as fixed but with no trailing zeros looking like integers.

I think I need to stop the fixed manipulator's effect after the storage of the square root of the number, how do I do that, or is it something else that I need to reset?

Here is the code, and sorry if it is not as pretty as others, if you know how to make it pretty let me know.

Thanks

//Send the results to Data file.
outputFile << noshowpoint; //Change Formatting.
outputFile << setw(3) << iCounter << "\t";
outputFile << setw(7) << dNumber << "\t\t";
outputFile …

Waseemn 0 Light Poster

Thank You Narue

Wow!!! I love the code, color, line numbers what one can ask for?

Could you tell me how this was done so that if I need to post any code snipits they would look nice and readable like yours?

Thanks for explaining the code too, will definitely come in handy.

Cordially

Waseem

Waseemn 0 Light Poster

Thank You Ancient Dragon,

I will look into this and send more questions once they arise.

Thanks again,

Cordially

Waseem

Waseemn 0 Light Poster

Hi,

I just posted a question and I saw yours, so I wanted to share my 2cents worth of ideas with you.

To answer the question what to do if the answer is No to the first 2 conditions.

Well lets take it step by step if the answer is No to the first condition that is Major != "Bus" then you will need to skip it and go on to the next record. You need alums with major = "Bus" and nothing else.

same thing goes for the 2nd condition, if it is not equal to 1984 even though major = "Bus" you toss it out and go on to the next record.

Until you reach the end of the Alumni File, you keep searching for these two conditions. Once you reach the end of the file, well you are done them.

I also suggest to keep the count each time you find a record, so after the line:

Printf "Alumnus Number","Alumnus Name"

You would increment the counter by 1 say using something like

counter++ or ++counter

I hope this helps...

I am a beginning Prog Logic and Design student. I have a project to write pseudocode and draw a flow chart to do the following. From an Alumni File I have the following fields

Alumnus Number
Alumnus Name
Year Graduated
Major

I want to get all Alumni With a Major in Bus, who graduated …

Waseemn 0 Light Poster

Hello All

I an taking a class in C++. Though I have had many years programming, it is an introductory class because one needs to learn the syntax and rules of the new language.

I am writing a program that stores data in a file, and retrieves data from a file and I need to format that data so it will have a structure. What I have elected to do is ask the user for how many numbers to store in the datafile, and then the code will generate that many "random" numbers, calculate the square root, squared, and cubed values of that these 'random" numbers and store the data in columns.

My questions are:

1) How do I make the retrieval code get the "random" number , its square root, squared, and cubed values when these are all on the same line? Is there a way to use something like:

inFile >> num1;
inFile >> num2; and have this line read the next value over on the same line vs. one line below. BTW inFile is set to ifstream to read from the data file using the preprocessor directive #include<fstream>

Do I need to read the whole line and then parse it, and how would one parse a tab delimited line of text?

2) I know what showpoint does, it forces the display of the decimal point, but can I selectively turn it on and off and how?

Thanks for …