bluebird 0 Junior Poster in Training

yes. The program reads the second line " Long time no see"
The program reads until the next line.
How should I do that?

bluebird 0 Junior Poster in Training

I try to read a file and display the data on the TextField.
But it does not read the next line.
For example, for two lines,

How are you? Long time no see.
I remember you.

The program does not show the sentence "I remember you"
How should i do that?

try {
			
			
			fileconnection=(FileConnection)Connector.open(path+filedir);
			InputStream is=fileconnection.openInputStream();
			ByteArrayOutputStream baos=new ByteArrayOutputStream();
			byte[]buffer=new byte[1024];
			int bytesRead=0;
			while((bytesRead=is.read(buffer))!=-1)
			{
				baos.write(buffer,0,bytesRead);
				TFileReadWriteMIDlet.tfilereadwritemidlet.mainform.txtfield.setString(baos.toString());
			}
			
			//TFileReadWriteMIDlet.tfilereadwritemidlet.mainform.txtfield.setString(baos.toString());
		
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
bluebird 0 Junior Poster in Training

Can we use the same kind of phone to execute a MIDlet and a wince.net programs?
What are the advantages of MIDlet over wince.net programs?

bluebird 0 Junior Poster in Training

In c programming language, When the compiler compiles a program, the obj file is created. When that object file is run, an .exe file is generated.
That .exe file contains the machine language instructions that are understandable by the underlying processor.
If we run that .exe file on another kind of processor [say processor x], that processor will not understand that machine language instruction.
But if we compile that source code again in that processor, will the compiler produce the machine language instruction that is understandable by that processor?
I mean platform dependent problem will occur only when we want to distribute .exe file?
There will not be problem if we get the whole source code (.c) file?

In Java programming, the compiler produces .class file. That file includes the byte codes that are understandable by JVM.
If we want to contribute our s/w, but not the source code [like .exe file in c], we can distribute .class file?
We can execute that .class file on any processor. But we can not read the source code of that?
That is right?

bluebird 0 Junior Poster in Training

In a manifest file, there is an attribute of MIDlet-version.
What is MIDlet-version?
A MIDlet is an application that uses the Mobile Information Device Profile (MIDP) of the Connected Limited Device Configuration (CLDC) for the Java ME environment
So MiDlet is an application we wrote.
What is the meaning of MIDlet-version number?

bluebird 0 Junior Poster in Training

Hi,
In a mobile programming training center, the major subjects are j2me and wince.net.
But before those subjects, they also teach os subject about the topic of process scheduling, memory management, virtual memory and so on.
What is the benefit of teaching that subject?
Is it necessary to teach that subject for j2me and wince.net?

bluebird 0 Junior Poster in Training

Hello all!

I installed a j2me prgram into Nokia N95 8GB and tested that.
It works properly. But after a few minutes, the screen of my Nokia phone showed nothing and black as it was shut off. But I can see the light on the soft button and select buttons ( not on the keypad )
I thought that it might be because of low battery power. But After charging for a few hours, it is still the same. I pressed the power button. But the screen was still black as it was shut off and the buttons are still the same.
What is the problem?

Can Virus be the reason? If so, how can I solve that problem? The computer even does not know that device anymore and ask me to check whether the phone was locked or not.

Please help me.

bluebird 0 Junior Poster in Training

Hi,
I have found the error.
I forgot to write this line when the contact name information is written.
contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name_struct);

Thanks for pointing out a good extensive tutorial .

bluebird 0 Junior Poster in Training

Hi,
I encounter the problem of not being able to read the information from the contact list.
It is ok to read organization name and email. But I can not read the name information.
I get the exception message of
java.lang.IndexOutOfBoundsException: Empty field: 106>, Exception caught in Display class
What is the problem? At first, I read the org information and show that information in the list. When the user chooses one organization name from the list, it will show the name associated with that organization.
I think there is error not only in the part of reading name information, but also in part of showing that data because it shows the following exception message when I just try to display the email information .
TRACE: <at java.lang.NullPointerException: 0>, Exception caught in Display class
java.lang.NullPointerException: 0


//ZSecondContactMIDlet .java

package zthirdcontact;
import java.util.Enumeration;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.pim.*;


public class ZSecondContactMIDlet extends MIDlet implements CommandListener{
	static ZSecondContactMIDlet zsecondcontactmidlet;
	Form mainForm;
	StringItem stItem;
	Display display;
	Command cmdExit;
	Command cmdRead;
	Command cmdDelete;
	Command cmdWrite;
	
	

	public ZSecondContactMIDlet() {
		mainForm=new Form("Contact Program");
		stItem=new StringItem("*******","Data has been entered");
		cmdExit=new Command("Exit",Command.EXIT,0);
		cmdRead=new Command("Read",Command.SCREEN,0);
		cmdDelete=new Command("Delete",Command.SCREEN,0);
		cmdWrite=new Command("Write",Command.SCREEN,0);
		
		
		mainForm.append(stItem);
		mainForm.addCommand(cmdRead);
		mainForm.addCommand(cmdExit);
		mainForm.addCommand(cmdDelete);
		mainForm.addCommand(cmdWrite);
		mainForm.setCommandListener(this);
		display=Display.getDisplay(this);
		Verify();
		
		
		
		
	}

	
	private void Verify() {
		String version=System.getProperty("microedition.pim.version");
		if(version==null)
		{
			System.out.println("PIM is not available");
		}
		
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	} …
bluebird 0 Junior Poster in Training

Hi,
I am a beginner in j2me programming. Whenever I encounter an error message, it is difficult for me to find the place where the mistake exists. I do not get any hint from the error message. For example, in this message, what is the meaning of bci=0? What does bci stands for?
I am sorry if this is a stupid question.
java.lang.NoClassDefFoundError: ListCommandHandler
- java.lang.Class.invoke_verify(), bci=0
- java.lang.Class.initialize(), bci=117
- java.lang.Class.forName(), bci=0
- com.sun.midp.main.CldcMIDletLoader.newInstance(), bci=1
- com.sun.midp.midlet.MIDletStateHandler.createMIDlet(), bci=66
- com.sun.midp.midlet.MIDletStateHandler.createAndRegisterMIDlet(), bci=17
- com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=27
- com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
- com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
- com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
- com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

bluebird 0 Junior Poster in Training

Hi
I am testing to write a contact list program. I store the information regarding name, Organization name, tel no and e-mail. When I select the read command, it shows all the organization name, e-mail in the list. It is all ok so far.
I want to write the program as when I choose one contact [organization name, e-mail] in the list, I want to show the detail info [name, organization name, email, tel no].
But now the program is showing java.lang.NoClassDefFoundError: ListCommandHandler error message.
What is the problem?

import java.util.Enumeration;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.pim.*;


public class ZSecondContactMIDlet extends MIDlet implements CommandListener{
	Form mainForm;
	StringItem stItem;
	Display display;
	Command cmdExit;
	Command cmdRead;
	Command cmdDelete;
	Command cmdWrite;
	
	

	public ZSecondContactMIDlet() {
		mainForm=new Form("Contact Program");
		stItem=new StringItem("*******","Data has been entered");
		cmdExit=new Command("Exit",Command.EXIT,0);
		cmdRead=new Command("Read",Command.SCREEN,0);
		cmdDelete=new Command("Delete",Command.SCREEN,0);
		cmdWrite=new Command("Write",Command.SCREEN,0);
		
		
		mainForm.append(stItem);
		mainForm.addCommand(cmdRead);
		mainForm.addCommand(cmdExit);
		mainForm.addCommand(cmdDelete);
		mainForm.addCommand(cmdWrite);
		mainForm.setCommandListener(this);
		display=Display.getDisplay(this);
		Verify();
		
		
		
		
	}

	
	private void Verify() {
		String version=System.getProperty("microedition.pim.version");
		if(version==null)
		{
			System.out.println("PIM is not available");
		}
		
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		
		display.setCurrent(mainForm);

	}

	public void commandAction(Command c, Displayable d) {
		
		
		if(c==cmdExit)
		{
			try {
				destroyApp(true);
				notifyDestroyed();
			} catch (MIDletStateChangeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		if(c==cmdWrite)
		{
			
				PIM pim=PIM.getInstance();
				ContactList contactlist=null;
				Contact contact=null;
				try {
					contactlist=(ContactList)pim.openPIMList(PIM.CONTACT_LIST,PIM.WRITE_ONLY);
					contact=contactlist.createContact();
					String[]name_struct=new String[contactlist.stringArraySize(Contact.NAME)];
					name_struct[Contact.NAME_GIVEN]="Rose";
					name_struct[Contact.NAME_FAMILY]="Angel";
					contact.addString(Contact.ORG, PIMItem.ATTR_NONE, "Microsoft");			
					contact.addString(Contact.TEL, PIMItem.ATTR_NONE, "099045464");
					contact.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "rose@gmail.com");
					contact.commit();
				} …
bluebird 0 Junior Poster in Training

Hi
Thank you very much, Peter_budo.
Now, the program shows all the records very beautifullyyy. You helped a lot to me.

But I am still confused. Even if I did not create new instance of DataInputStream and ByteArrayInputStream, I think the program should not show the blank for the next records. It should show just the first record as the data of the other records[ the data that has been in the DataInputStream]. Why it shows the blank?
Here is the program I wrote before this reservation program. There is no difference between these two programs in the part of reading recordstore.
I don’t create new instance of DataInputStream and ByteArrayInputStream in that program but it shows all the records. Why?

I am sorry if my question is a very stupid one. May be it is because I don’t understand about the concept of stream. Please point out if there is any tutorial or book I should read about that.

package zbmixedrecordenumeration;

import java.io.*;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.*;

public class CommandHandler implements CommandListener {
	RecordStore recordstore=null;
	RecordEnumeration recordenumeration=null;
	Alert alert;
	Display display;

	public CommandHandler() {
		// TODO Auto-generated constructor stub
	}

	public void commandAction(Command c, Displayable d) {
		MainForm mainform=(MainForm)d;
		if(c==mainform.cmdExit)
		{
			try {
				MixedRecordMIDlet.mixedrecordmidlet.destroyApp(true);
			} catch (MIDletStateChangeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			MixedRecordMIDlet.mixedrecordmidlet.notifyDestroyed();
		}
		
		if(c==mainform.cmdWrite)
		{
			byte[] outputRecord=null;
			String outputString[]={"First Record","Second Record","Third Record"};
			String test[]={"aa","bb","cc"};
			String test2[]={"a1","b1","c1"};
			//int outputInteger[]={1,2,3};
			//boolean outputBoolean[]={true,false,true};
			ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
			DataOutputStream outputDataStream=new DataOutputStream(outputStream); …
bluebird 0 Junior Poster in Training

Hi,
Thanks for your kind replies. But I still didn’t get it.
I put the alert outside the while loop because I want to show the entire booking.
And the record shown by my program is not the last record. It only shows the first record and blank for the rest. I can say that it shows the blank because I append the string “What is the problem?” to the buffer after the while loop.
For example, if the first record I book is John, Tokyo, Newyork, then if I choose displaybookinglist command, the program shows like that
John
Tokyo
Newyork
What is the problem?

After that , if I book the second record, Thomas, Tokyo, Seoul, then if I choose displaybookinglist command, the program shows like that
John
Tokyo
Newyork
[blank here]
[blank here]
[blank here]
What is the problem?

As you suggest me, I put the alert box in the while loop. But it does not work.
And I declared the RecordStore and RecordEnumeration above the command action.
And I have also closed the recordstore. Here is my a little updated coding.

What is the problem?
Please help me.

package zsecondreservation;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

public class ReservationCommandHandler implements CommandListener {
	RecordStore recordstore=null; …
bluebird 0 Junior Poster in Training

Hi!
No one replied to my last question because of my mistake. I did not ask clearly what I want to know and posted complex unsystematic code that are not necessary to show here. I am very sorry to distrub u all.
I have modified my program as follows.
User can enter data and that will be stored in a Recordstore when the user clicked the book command. All input records will be shown when the user chooses the displayreservation list command.
But my program can show only one record and it just shows only the blank for the rest of the records in the recordstore.

And my program does not store that data permanently in the Recordstore. Whenever I close the program, that data are lost. I have to enter that data again.

What are the errors? Please help me.

package zsecondreservation;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

public class ReservationCommandHandler implements CommandListener {

	public ReservationCommandHandler() {
		// TODO Auto-generated constructor stub
	}

	public void commandAction(Command c, Displayable d) {
		
		ReservationForm reservationform=(ReservationForm)d;
		RecordStore recordstore=null;
	    RecordEnumeration recordenumeration=null;
		
		if(c==reservationform.cmdLogout)
		{
			ZSecondReservationMainform zreservationmainform=new ZSecondReservationMainform("login From");
			Display display=Display.getDisplay(ZSecondReservationMIDlet.zreservationmidlet);
			display.setCurrent(zreservationmainform);
		}
		
		if(c==reservationform.cmdBook)
		{
			try {
				recordstore=RecordStore.openRecordStore("reservationlist",true);
				
			} catch (RecordStoreException e) {
				Alert alert=new Alert("Error Creating",e.toString(),null,AlertType.ERROR);
				Display display=Display.getDisplay(ZSecondReservationMIDlet.zreservationmidlet);
				display.setCurrent(alert);
				
				
			}
			byte[] OutputRecord;
			ByteArrayOutputStream outputstream=new ByteArrayOutputStream();
			DataOutputStream outputdatastream=new DataOutputStream(outputstream);
			try {
				outputdatastream.writeUTF(reservationform.tfName.getString());
				outputdatastream.writeUTF(reservationform.cgFrom.getString(reservationform.cgFrom.getSelectedIndex()));
				outputdatastream.writeUTF(reservationform.cgTo.getString(reservationform.cgTo.getSelectedIndex()));
				outputdatastream.flush();
				
				OutputRecord=outputstream.toByteArray();
				System.out.println(OutputRecord);
				recordstore.addRecord(OutputRecord, …
bluebird 0 Junior Poster in Training

Hi!
I am tryig to write a simple j2me MIDlet program.
Using that program, a user has to fill the required information to make an air reservation. And he also can see the resersation list.
I used the Recordstore to write and read again that reservation list. But my program does not show any list. I think It even does not write the list in the recordstore.
Where is the error?

Here is my program.
//ZSecondReservationMIDlet.java

package zsecondreservation;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class ZSecondReservationMIDlet extends MIDlet {
	
	static ZSecondReservationMIDlet zreservationmidlet;
	ZSecondReservationMainform zreservationmainform=new ZSecondReservationMainform("login From");
	Display display=Display.getDisplay(this);
	
	
	

	public ZSecondReservationMIDlet() {
		ZSecondReservationMIDlet.zreservationmidlet=this;
		
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		display.setCurrent(zreservationmainform);
		
		// TODO Auto-generated method stub

	}

}

/////ReservationForm.java

package zsecondreservation;

import javax.microedition.lcdui.*;
//import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

public class ReservationForm extends Form{
	TextField tfName=new TextField("Name","",7,TextField.ANY);
	ChoiceGroup cgFrom=new ChoiceGroup("From",ChoiceGroup.POPUP);
	ChoiceGroup cgTo=new ChoiceGroup("To",ChoiceGroup.POPUP);
	DateField  cgDate=new DateField("Date",DateField.DATE_TIME);
	ChoiceGroup cgTime=new ChoiceGroup("Time",ChoiceGroup.EXCLUSIVE);
	ChoiceGroup cgFood=new ChoiceGroup("Food",ChoiceGroup.EXCLUSIVE);
	TextField tfMobile=new TextField("Mobile no","",9,TextField.PHONENUMBER);
	Command cmdLogout=new Command("Logout",Command.SCREEN,0);
	Command cmdBook=new Command("Book",Command.SCREEN,0);
	Command cmdDisplayBookingList=new Command("DisplayBookingList",Command.SCREEN,0);
	

	public ReservationForm(String s) {
		super(s);
		append(tfName);
		cgFrom.append("Singapore",null);
		
		cgFrom.append("Bangkok",null);
		append(cgFrom);
		cgTo.append("Tokyo",null);
		cgTo.append("Seoul",null);
		append(cgTo);
		append(cgDate);
		cgTime.append("Morning", null);
		cgTime.append("Evening", null);
		append(cgTime);
		cgFood.append("Veg",null);
		cgFood.append("non-veg",null);
		append(cgFood);
		append(tfMobile);
		addCommand(cmdLogout);
		addCommand(cmdBook);
		addCommand(cmdDisplayBookingList);
		setCommandListener(new ReservationCommandHandler());
		
		
	}

}

//////ReservationCommandHandler.java

package zsecondreservation;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore; …
bluebird 0 Junior Poster in Training

Hi everybody

I am a beginner of j2me programming. I am reading a book regarding J2ME programming and that book is ok for me.

But when I came across j2me programms of my friend, they are very complex for me although I know the basic things. For example, I thought that I understand the concept of high level userinterface. I mean the concept of Textbox, list, Form and so on. But the examples given in the book uses only one MIDlet class and all are written in that class. But In my friend's program, they are partitioned, such as MainForm class, MainMidlet class ,and a class that is for CommandAction() and so on. He also use static ( Forexample if the MIDlet class name is FirstMIDlet, He declares as

static FirstMIDlet firstmid;

and He uses as FirstMIDlet.firstmid in other classes. I can guess why we should use static like that because I before know the concept of static. But I want to know step by step explanation exactly how to write j2me programs like that.

How should I do?

Is there any free ebook that is suitable for me?

Thanks in advance.

bluebird 0 Junior Poster in Training

Can someone tell me that statement is true or false?
RARP allows a host to discover internet address of other network hosts when it knows only its physical address.
Thanks in advance.

bluebird 0 Junior Poster in Training

Can somebody tell that statement is true of false?
The session layer is the network dialog layer it allows the communication between two process to take place in either half duplex or full duplex mode.

bluebird 0 Junior Poster in Training

Can someone explain any one advantage and any one disadvantage of star topology in comparison to mesh topology?

bluebird 0 Junior Poster in Training

Hi Everybody!
I have installed those materials and but it still does not work.
When I looked at the coding of that samples, I think they are not wirtten in c#.
Now I found a program and explaination from a site http://www.miszalok.de/C_3D_MDX/C1_Moving_Triangles/Tutorial1.pdf

But that program also does not work.
Can anybody tell me how to test that the program and if there is any error, how to correct the error?

Thank you very much!

bluebird 0 Junior Poster in Training

And when i execute the sample program,
the deployment error occur and the error message is that
" unable to start program '%CSIDL_PROGRAM_FILES%\tuto2_vertices\tuto2_vertices.exe'.
The system cannot find the file specified.

bluebird 0 Junior Poster in Training

If I installed visual studio 2005, is there any side effect to my exiting visual studio 2008?
and instead of Windows Mobile 5.0 Pocket PC SDK,
which Sdk shoud i install?
Tell me exactly.
don't get me wrong.
I have no knowledge about that.
So I have to know that exactly.
And thank you for your help.

bluebird 0 Junior Poster in Training

Why should i change older sdk?
Why I can not execute the sample program provided by window mobile 5.0 SDK R2 on that SDK?

bluebird 0 Junior Poster in Training

I am using window xp.
and visual studio 2008.
This is the messages written in readme file.


Code Sample Name: tut02_vertices

Feature Area: Direct 3D Mobile

Description:
In this tutorial, we are rendering some vertices. This introduces the
concept of the vertex buffer, a Direct3D Mobile object used to store
vertices. Vertices can be defined any way we want by defining a
custom structure and a custom FVF (flexible vertex format). In this
tutorial, we are using vertices that are transformed (meaning they
are already in 2D window coordinates) and lit (meaning we are not
using Direct3D Mobile lighting, but are supplying our own colors).

Usage:
Build and run on device

Relevant APIs/Associated Help Topics: Direct 3D Mobile, CreateVertexBuffer

Assumptions: Direct 3D Mobile support

Requirements:
Visual Studio 2005,
Windows Mobile 5.0 Pocket PC SDK,
ActiveSync 4.0.

** For more information about this code sample, please see the Windows Mobile SDK help system. **


It says that it has required Visual Studio 2005. Can I run it on 2008?
and it says that it Usage:
Build and run on device


What is the meaning of device there?

I am sorry if my questions are stupid.

Thanks for replying me.

bluebird 0 Junior Poster in Training

Hello everybody!
I would like to get some sample programs for
DirectDraw - For drawing shapes, objects, painting on the screen for games, etc
Direct3D - For 3D rendering
DirectShow - For video and multimedia.
I have little knowledge about programming and wince.net.
But I have been assigned a duty to present some sample programs and explain the function of that programs.
So the first step I have to do now is to find sample programs.
I have tested some sample programs provided in Windows Mobile 5.0 SDK R2. But it does not work. It shows deployment errors.
I don't know the problem.
Please help me.

Thanks in advance.

bluebird 0 Junior Poster in Training

Hello everybody!

Please help me.

Sorry!
It is just a mistake.
I want to know how to overload the logical operators !, && and ||.
I have to do assignment regarding operator overloading and I have written other operators except that 3 operators.
Please show me an example.

I have to do right now. So please help me now.
I understand I should not say like that.
But I really need your help instantly.
Please help me.

bluebird 0 Junior Poster in Training

Hello everybody!

Please help me.

bluebird 0 Junior Poster in Training

Can somebody help me?

bluebird 0 Junior Poster in Training

In this program, although I use Ignore(1000,’\n’); why it does not show the title for tape.
In fact, I don’t understand very well about Ignore(); what is the meaning of 1000 in that function?

#include<iostream.h>
class Publication
{
 char title[20];
 float price;

 public:
 void putdata()
 {
 cout<<"\nEnter title:";
 cin.getline(title,20);
 cin.ignore(1000,'\n');
 cout<<"\nEnter price:";
 cin>>price;
 }

 void getdata()
 {
  cout<<"\nTitle:"<<title;
  cout<<"\nPrice:"<<price;
 }

};

class Book:public Publication
{
 int pgcount;

 public:
 void putdata()
 {
  Publication::putdata();
  cout<<"\nEnter page count";
  cin>>pgcount;
 }
 void getdata()
 {
  Publication::getdata();
  cout<<"\nPage Count:"<<pgcount;
  }


};

class Tape:public Publication
{
 float ptime;

 public:

 void putdata()
 {

  Publication::putdata();
  cout<<"\nEnter playing time:";
  cin>>ptime;
 }

 void getdata()
 {
  Publication::getdata();
  cout<<"\nPlaying time:"<<ptime;
 }
 };

int main()
{
 Book b1;
 Tape t1;

 b1.putdata();
 t1.putdata();
 b1.getdata();
 t1.getdata();
 return 0;
 }
bluebird 0 Junior Poster in Training

The assignmento I have to write is to Derive a class DistSign from class Distance which contains inches and feet as a protected data, to add unary + or – to the distance. Write no argument and two argument constructor.

Here is my program. I don’t know how to add + operator.

#include<iostream.h>
class Distance
{
protected:
int feet;
float inches;

public:
Distance()
{
 feet=0;
 inches=0;
}
Distance(int f,float in)
{
 feet=f;
 inches=in;
}
void display()
{
 cout<<"\nfeet:"<<feet;
 cout<<"\ninches:"<<inches;
 }
};

class DistSign:public Distance
{
  public:

  DistSign(int f,float in):Distance(f,in)
   {}

  void operator-()
  {
     feet*=-1;
    inches*=-1;

  }
bluebird 0 Junior Poster in Training

I am writing a program to record score of a cricket match. One array stores information of batting teams and the other array stores information of bowling team.
The program has to read the information of the teams and depending upon the user’s choice, it must displays either the batting team or the bowling team’s information.
My program does not display the information correctly.
What is the problem?

#include<iostream.h>
struct batting{
char name[20];
int score;
int out;
};

struct bowling{
char name[20];
int maiden;
int runs;
int wickets;
};

int main()
{

 int i,j;
 cout<<"How many number of batting&bowling team:";
 cin>>i;

 batting *bat=new batting[i];
 batting *bat1;
 bowling *bow=new bowling[i];
 bowling *bow1;


 for(j=0;j<i;j++)
 {
 bat1=&bat[j];
 cout<<"\nEnter name:";
 cin.getline((*bat1).name,20);
 cin.ignore(1000,'\n');
 //cin.ignore();
 cout<<"\nEnter score:";
 cin>>(*bat1).score;
 cout<<"\nIndication out(out=1&in=0)";
 cin>>(*bat).out;
 }
  for(j=0;j<i;j++)
 {
 bow1=&bow[j];
 cout<<"\nEnter name:";
 cin.getline((*bow1).name,20);
 cin.ignore(1000,'\n');
 cout<<"\nEnter maiden:";
 cin>>(*bow1).maiden;
 cout<<"\nEnter no: of runs";
 cin>>(*bow1).runs;
 cout<<"\nEnter wickets no:";
 cin>>(*bow1).wickets;
 }


 int k=0;

 cout<<"\n*******Which Information You would like to know?*******";
 cout<<"\nEnter 1 for Batting team && 2 for bowling team";
 cin>>j;
 if(j==1)
 for(k=0;k<i;k++)
 {
  bat1=&bat[k];
  cout<<"\nName:"<<(*bat1).name;
  cout<<"\nScore:"<<(*bat1).score;
  cout<<"\nOut:"<<(*bat1).out;
 }
   return 0;
 }
bluebird 0 Junior Poster in Training

Thank you for your reply.
But I have not got it.
I don't understand what u said.

bluebird 0 Junior Poster in Training

hello everybody!

As far as I understand, the functions that are only different in return type are not allowed.
But how can I write the program for the following question?
*****************************************
Create two classes DM and DB which store the value of distances. DM stores distances in meters and centimeters and DB in feet and inches. Write a program that can read values for the class objects and add one object of DM with another object of DB. Use a friend function to carry out the addition operation. The object that stores the result may be a DM object or DB object, depending on the units in which the results are required. The display should be in the format of feet and inches or meters and centimeters depending on the object on display.
****************************************
Here is my program. It does not work.
please help me. Thanks in advance.

#include<iostream.h>

class DB;
class DM
{
float   me,cm;
public:
DM()
{}


DM(float m,float c)
{
 me=m;
 cm=c;
}
friend DB operator+(DM,DB);

};

class DB
{
float ft;
float inches;

public:
DB()
{}

DB(float f,float in)
{
ft=f;
inches=in;
}
void display()
{
 cout<<"\nfeet:"<<ft;
 cout<<"\ninches:"<<inches;
 }




friend  DB operator+(DM,DB);


};


DB operator+(DM m, DB b)
{
 DB b2;
 m.cm+=m.me*10;
 b.inches+=b.ft*12;
 b2.inches=m.cm*0.3937+b.inches;
 while(b2.inches>=12)
 {
  b2.ft++;
  b2.inches-=12;
 }
 return b2;
}

int main()
{
DM dm1 (1,9);
DB db1(1,1);
DB db2;
db2=dm1+db1;
db2.display();

return 0;
}
bluebird 0 Junior Poster in Training

Hello
I am writing a file program like that user has to input a string and that string
was written to a file. From that file, that string was read to the another file changing lower case letters to upper case letters and upper case letters to lower case letters.
In my ogram outputs one more character in the second file.
I have been looking for the error,but I can't find. What is the error?

#include<stdio.h>
#include<string.h>

int main()
{
FILE *ptr,*ptr1;

char org[30];
char upper[30];
char lower[30];
char change[30];
int i=0,count=0;

if((ptr=fopen("original.txt","w"))!=NULL)
{
printf("\nEnter a string");
gets(org);
fputs(org,ptr);


}
 fclose(ptr);

if((ptr=fopen("original.txt","r"))!=NULL)
{
if((ptr1=fopen("changecase.txt","w"))!=NULL)
{



 while(!feof(ptr))
 {
  org[i]=getc(ptr); printf("%c",org[i]);
  i++;
  count++;

 }
 org[i]='\0';



 for(i=0;i<count;i++)
 {
  upper[i]=toupper(org[i]);
  lower[i]=tolower(org[i]);
 }

 upper[i]='\0';
 lower[i]='\0';



 for(i=0;i<count;i++)
 {
  if(org[i]==upper[i])
     change[i]=lower[i];
     else change[i]=upper[i];
 }


change[i]='\0';

fputs(change,ptr1);

}
}
return 0;
}
bluebird 0 Junior Poster in Training

Hello!
I am trying to write a program that test whether a word is present in a file or not using command line argument.
Here is my program. It does not work properly. Although the word I entered is present in the file, it has been saying that " the word is not present in the file". What is the problem?

thanks in advance.

#include<stdio.h>
#include<string.h>
int main(int argc,char*argv[])
{
 FILE*ptr;
 char input[100];
 char fstring[100];

 int i=0;
 char* cptr;
 strcpy(input,argv[1]);




 if((ptr=fopen("hello.txt","r"))!=NULL)
 {
     while(!feof(ptr))
     {
       fstring[i++]=getc(ptr);
     }
 }

     fstring[i]='\0';

     ///////////////


     cptr=strstr(fstring,input);
     if(cptr!=NULL)
      printf("%s is present in file",argv[1]);
      else printf("%s is not present in file",argv[1]);

  return 0;
}
bluebird 0 Junior Poster in Training

Hello!
I am writing c++ program on linux.
Whenever I read a char or string, I got problem.
In c, I sove the problem using
if(getchar()=='\n')
in c++, how can I sove that problem?
Here is my program. I cannot do any input for name.
Please help me.

#include<iostream.h>
struct Student
{
int rno;
char name[20];
int  cmark;
int  osmark;
int  javamark;

void setdata()
{
cout<<"\nEnter rno:";
cin>>rno;
cout<<"\nEnter name:";
//if(getchar()=='\n');
cin.getline(name,20);
cout<<"\nEnter mark for c:";
cin>>cmark;
cout<<"\nEnter mark for os:";
cin>>osmark;
cout<<"\nEnter mark for java:" ;
cin>>javamark;
}
void testdata()
{
int fcount=0;


if(cmark<=40)fcount++;
if(osmark<=40)fcount++;
if(javamark<=40)fcount++;
if(fcount>1)
cout<<"\n"<<rno;
}

};
int main()
{
struct Student stu[3];
int i;
for(i=0;i<3;i++)
stu[i].setdata();
cout<<"\nFailed list";
for(i=0;i<3;i++)
stu[i].testdata();


return 0;
}
bluebird 0 Junior Poster in Training

Yes.
I intended to post in c. I don't know how it was get to the Geek's Lounge.

bluebird 0 Junior Poster in Training

hello
Is there any way to change numeric to figures?
for example if the user input is 134, the program output must be one three four.


thanks in advance,
Bluebird

bluebird 0 Junior Poster in Training

hello!

How can I display if the query results more than one value?
For example, how can I do a query that produces all pairs of salespeople who are living in the same city.


Thanks in advance.

bluebird 0 Junior Poster in Training

Hi Salem,Fneaky-Chris and MosaicFuneral

Thank u so much for answers.
It is a great help for me.


Thanks again!

bluebird 0 Junior Poster in Training

I would like to change the case of the string value.
(lower case letter to upper case and upper case letters to lower case)
I wrote my program as the following. But linux does not know strlwr and strupr functions.
What should I do?

#include<iostream.h>
#include<conio.h>
#include<string.h>
const int size=80;

class Reverse
{
char letter[size];
char change[size];

public:

void read()
{
cout<<"\nEnter a letter:";
cin.getline(letter,size);
}

void print()
{
cout<<"\n*******Reverse case version*******";
cout<<endl<<change;
}
void convert();
};

void Reverse::convert()
{
char lower[size];
char upper[size];
//char change[size];
strcpy(lower,letter);
strcpy(upper,letter);
strlwr(lower);
strupr(upper);
int length=strlen(letter);
for(int i=0;i<length;i++)
{
if(letter[i]==lower[i]) {change[i]=upper[i]; }
else change[i]=lower[i];

}
change[i]=NULL;
}
int main()
{
Reverse r1;
r1.read();
r1.convert();
r1.print();
getch();
return 0;
}
bluebird 0 Junior Poster in Training

Hello!
I am trying to add new data into a database.
What is the mistake in my code?
I got the error message such as "general error".

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class AddRecord implements ActionListener{
    private ScrollingPanel fields;
    private JTextArea output;
    private Connection connection;
    public AddRecord(Connection c, ScrollingPanel f, JTextArea o)
    {
     connection =c;
     fields=f;
     output=o;
    }
    public void actionPerformed( ActionEvent e)
    {
      try {
           Statement statement=connection.createStatement();
           if( !fields.last.getText().equals("")&&
                !fields.first.getText().equals("")){
                String query="INSERT INTO addresses ("+
                "firstname, lastname, address, city,"+
                "stateorprovince, postalcode, country,"+
                "emailaddress, homephone, faxnumber"+
                ") VALUES ('"+
                fields.first.getText()+"','"+
                fields.last.getText()+"','"+
                fields.address.getText()+"','"+
                fields.city.getText()+"','"+
                fields.state.getText()+"','"+
                fields.zip.getText()+"','"+
                fields.country.getText()+"','"+
                fields.email.getText()+"','"+
                fields.home.getText()+"','"+
                fields.fax.getText()+"')";
            output.append("\nSending query:"+ connection.nativeSQL(query)+"\n");
            int result=statement.executeUpdate(query);
            if (result==1)
              output.append("\nInsertion successful\n");
              else {
               output.append("\nInsertion failed\n");
               fields.first.setText("");
               fields.last.setText("");
               fields.address.setText("");
               fields.city.setText("");
               fields.state.setText("");
               fields.zip.setText("");
               fields.country.setText("");
               fields.email.setText("");
               fields.home.setText("");
               fields.fax.setText("");
              }
          }
          else
           output.append("\nEnter at least first and "+
                         "last name then press Add\n");
           statement.close();
          }
          catch (SQLException sqlex){
           sqlex.printStackTrace();
           output.append(sqlex.toString());
           }
          }
        }
bluebird 0 Junior Poster in Training

Hello! hollystyles

Thanks for your reply.
Now it is working.

bluebird 0 Junior Poster in Training
String query="SELECT *FROM addresses"+
                     "WHERE lastname='"+
                     fields.last.getText()+"'";

What is wrong with the above SQL statement?
I got the error message as "Syntax error in FROM clause"

bluebird 0 Junior Poster in Training

Thank you for your reply.
I have got that objective question from this site.
http://www.indiastudycenter.com/studyguides/cs/objtest/c-optr.asp?
Now I am preparing for my exam.
Is there any web site that describes the objective type questions concerning programming in C?

bluebird 0 Junior Poster in Training

In the book I have read, * has higher precedence than +. But in the ture answer of that question is +. I think the answer is wrong.

bluebird 0 Junior Poster in Training

9. Which of the following operator has the highest precedence?
(1)*
(2)==
(3)=>
(4)+
Ans : 4


If I have to answer that question, I will choose the answer *.
Does + has higher precedence than *?
Please explain me.

bluebird 0 Junior Poster in Training

Hello!

Please help me!

I display the data from the arrylist xx in the table.
But the program shows the table several times.
I did not notice that before.
Now whenever I click the menu, it shows the table 26 times.
What is the problem? I am in trouble.
Please help me as soon as possible.

void jMenuItem5_actionPerformed(ActionEvent e) {if(irre.length()>5 && re.length()>5 ){                        ArrayList xx=Sallsubobj1.theList;            Collections.sort(xx, new columncomparator());            MyNode1 fl=new MyNode1(xx);            fl.setSize(640, 390);            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();            Dimension frameSize=fl.getSize();            fl.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);            fl.setVisible(true);           }  }
import javax.swing.*;import javax.swing.border.*;import javax.swing.table.*;import java.awt.*;import java.awt.event.*;import java.io.*;import java.util.*;import javax.swing.JOptionPane;public class MyNode1 extends JFrame{String []lptn=new String[]{"<subject> be noun",//1"<subject> passive-verb",//2"<subject> active-verb",//3"<subject> active-verb infinitive",//4"<subject> passive-verb infinitive",//5"noun be <obj>",//6"gerund <obj>",//7"infinitive <obj>",//8"active-verb infinitive <obj>",//9"passive-verb infinitive <obj>",//10"active-verb <obj>",//11"noun prep <np>",//12"passive-verb prep <np>",//13"active-verb prep <np>",//14"infinitive prep <np>"};//15  public ArrayList data;  JPanel jPanel1 = new JPanel();  JButton jButton1 = new JButton();      class MyTableModel extends DefaultTableModel      {           MyTableModel(ArrayList p)           {                 int i=0;                 this.addColumn("LinguisticPattern");                 this.addColumn("TriggerVerb");                 this.addColumn("RelevantConunt");                 this.addColumn("IrrelevantCount");                 this.addColumn("TotalCount");                 this.addColumn("RelevantRate");                 this.addColumn("Rank");                while(i<data.size())                {                      {                      Object[] obj=new Object[7];                            obj[0]=lptn[((Crules)p.get(i)).lp-1];                            obj[1]=((Crules)p.get(i)).tri;                            obj[2]=""+((int)(((Crules)p.get(i)).count));                            obj[3]=""+(int)(((Crules)p.get(i)).count1);                            obj[4]=""+(int)(((Crules)p.get(i)).totalcount);                            obj[5]=""+(double)((Crules)p.get(i)).relrate;                            obj[6]=""+(double)((Crules)p.get(i)).rank;                      this.addRow(obj);                      }                       i++;                 }            }      }      public MyNode1( ArrayList data)      {            super("RuleGen");this.data=data;            MyTableModel tm=new MyTableModel(data);            final JTable jt=new JTable(tm);            JScrollPane jsp=new JScrollPane(jt);            Container c=this.getContentPane();            c.add(jsp,BorderLayout.CENTER);            setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);            setContentPane(c);                }  public MyNode1() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    this.getContentPane().setLayout(null);    jPanel1.setBounds(new Rectangle(1, 370, 518, 43));    jPanel1.setLayout(null);    jButton1.setText("Sort");    jButton1.setBounds(new Rectangle(191, 17, 115, 20));    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent …
bluebird 0 Junior Poster in Training

Hello,
I use HTML to format the text in the list item strings.
But it does not work.
What is the problem?

public frmlist(ArrayList p,int mn) {
 enableEvents(AWTEvent.WINDOW_EVENT_MASK);
 ArrayList pp=new ArrayList();
String[] items;
for( int f = 0; f < p.size(); f++)
{String x1=new String();
String xx=new String();
String xx1=new String();
 
x1=lptn[((Crules)p.get(f)).lp-1];xx=x1;
x1=""+((Crules)p.get(f)).tri;xx=xx+x1+"   ";
 
//x1=""+((Crules)p.get(f)).lp;xx=x1+x2.substring(0,12-x1.length());
//x1=""+((Crules)p.get(f)).tri;xx=xx+x1+x2.substring(0,13-x1.length());
x1=""+((Crules)p.get(f)).count;xx=xx+x1+"   ";
x1=""+((Crules)p.get(f)).count1;xx=xx+x1+"    ";
x1=""+((Crules)p.get(f)).totalcount;xx=xx+x1+"    ";
x1=""+((Crules)p.get(f)).relrate;xx=xx+x1+"   ";
x1=""+((Crules)p.get(f)).rank;xx=xx+x1;//+x2.substring(0,12-x1.length())
xx="<HTML><pre>" + xx+ "</pre></HTML>";
pp.add(xx);
}
//JList jlist = new JList(items);
jList1 = new JList(pp.toArray());
jList1.setVisible(true);
}
bluebird 0 Junior Poster in Training

I don't know why I can not use this forum properly today. I can not show you the format I would like to write.
So please see the format of titled Similar Threads in this page.
In that format , there are 5 titles, thread, thread starter, forum, replies and last post.
Like that , I have titles like that
Linguistic pattern, relevant count, irrelevant count, total count , relevant rate and rank.
I have also save their values in the arraylist.
I don't know how to show them.