Thank You Friendz Especially Ezzaral.
Aia commented: Fine link +7
I want to learn JNI , please suggest me some basic guide.
use == instead of = in while
Thank you very much JamesCherrill , it solve my problem but still i am facing a problem is that how can i get focus of the place where i want to write some thing.
When I press 'A' on my On-screen Keyboard then It should generate the interrupt like hardware keyboard. I mean this. In vb Made on-screen keyboard we send the key but in java how can we do this?
I mean when I press 'A' in the keyboard it generate function like Normal Hardware Keyboard and writes that word.
I am making on-screen keyboard in java. All what i want to know is how to get focus into the notepad or any other typing point , I mean when i press a key it type it into the typing point like a keyboard do. If any one know any thing about this please help me. Any hint .... I will be thankful to you.
Thank You Very Much it solved my problem....
http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html
I think it will solve your Problem.
import javax.swing.*;
import java.awt.*;
public class keyboard
{
public static void main(String args[])
{
String s[] = {"esc","F1","F2","F3","F4","F5",
"F6","F7","F8","F9","F10","F11","F12",
"psc","slk","pau"};
JButton j[] = new JButton[s.length];
for(int i=0;i<s.length;i++)
j[i].setText(s[i]);
JFrame f = new JFrame();
for(int i=0;i<s.length;i++)
f.add(j[i],JFrame.LEFT_ALIGNMENT);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
I need Instant Help!. Code is giving me error of Null-Pointer Assignment, Please Any help me appreciated.
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
int main ()
{
srand((unsigned)time(0));
int add1, add2, sub1, sub2;
int multiply1, multiply2, div1, div2;
int choice=0, input;
add1 = (rand()%500)+1;
add2 = (rand()%500)+1;
sub1 = (rand()%500)+1;
sub2 = (rand()%98)+1;
multiply1 = (rand()%98)+1;
multiply2 = (rand()%8)+1;
div1 = (rand()%500)+1;
div2 = (rand()%8)+1;
int addAnswer = add1 + add2;
int subAnswer = sub1- sub2;
int multiplyAnswer = multiply1 * multiply2;
int divAnswer = div1 / div2;
//Display the menu and get the user's choice
while(choice!=5)
{
cout << " Geometry Calculator \n\n";
cout << "1. Addition\n";
cout << "2. Subtraction\n";
cout << "3. Multiplication\n";
cout << "4. Division\n";
cout << "5. Quit\n";
cout << "\n";
cout <<"Enter your choice (1-5): ";
cin >> choice;
cout << "\n";
if (choice==1)
{
cout << setw (6) << add1 << endl;
cout << "+ ";
cout << setw (4) << add2 << endl;
cout << "------";
cout << "\n";
cin >> input;
cout << "\n";
if
(input == addAnswer)
cout << "Congratulations\n";
else
cout << "That is incorrect,\nThe correct answer is: " << addAnswer;
cout << "\n";
return 0;
}
else if (choice==2)
{
cout << setw (6) << sub1 << endl;
cout << "- ";
cout << setw (4) << sub2 << endl;
cout << "------";
cout << "\n";
cin >> input;
cout << "\n";
if
(input == subAnswer)
cout << "Congratulations\n";
else
cout << "That is incorrect,\nThe correct answer is: " << subAnswer;
cout << "\n";
return 0;}
else if …
while (choice!=5)
{
Your Programme Body
}
Remember to Intialize Choice With any Number without 5
while (choice!=5)
{
Your Programme Body
}
Remember to Intialize Choice With any Number without 5
you have to declare functions before using them,,
return type function name (parameters list)
in your case
void studentDetails();
and call them
studentDetails();
dont write return type (void,int,....) when u r calling functions.
If we think that all books are in shelf and we want to keep a stock_record then..... i think it will be an attribute then.
I have made an erd having book,cutomer and shelf but i am confused in stock , i dont need any one to solve it completly but just tell me about stock , is stock a entity or attribute ?
Apply all steps of conceptual and logical database design on the following requirements:
The system should be able to store a customer’s name, address, and contact information and a book’s ISBN, publisher, authors, and title information. A customer should be able to purchase one or many books at a time. The system should store the purchase record of customers. It should give us the information in which shelf the book is lying by storing the shelf’s number, floor, and category information. Books are supplied by suppliers. They are stored in the stock. Number of books are deducted from the stock quantity as they are sold. Additional books are demanded from suppliers by looking at the stock record.
I know it is a stupidity to put this problem on c++ page but i got help from designer page so ...... i need a little help from programmers who know database.... I am stuck in this erd problem is only of stock , is stock an entity or attribute and if entity then what should i do and if it is an attribute then where should i place it , I guess book but i am not sure, please help me......
#include <stdio.h>
int main(void)
{
int N = 0 ;
char x[100] ;
int i=0;
FILE * input ;
input = fopen("weights.txt", "r") ;
if (input == NULL)
{
printf("failed to open input file\n") ;
return (0) ;
}
while(fscanf(input,"%c", &x[i]) !=EOF)
{
N++ ;
i++;
}
printf("The first value in the text file is %c\n", x[0]) ;
printf("The fifth value in the text file is %c\n", x[4]) ;
printf("The last value is the text file is %c\n", x[--N]) ;
printf("The number of values = %d\n", ++N) ;
return (0) ;
}
Check this out .....
3nf is industry standard normal form, you will not find any problem in inserting,deleting and updating a row if ur table is in 3nf.
Apply all steps of conceptual and logical database design on the following requirements:
The system should be able to store a customer’s name, address, and contact information and a book’s ISBN, publisher, authors, and title information. A customer should be able to purchase one or many books at a time. The system should store the purchase record of customers. It should give us the information in which shelf the book is lying by storing the shelf’s number, floor, and category information. Books are supplied by suppliers. They are stored in the stock. Number of books are deducted from the stock quantity as they are sold. Additional books are demanded from suppliers by looking at the stock record.
Problem : Is stock a separate entity or a attribute and where should i place stock record.
I guess Book but not sure exactly please i need help.
#include <alloc.h>
#include <conio.h>
#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
struct BMP
{
char Type[2]; //File type. Set to "BM".
unsigned long Size; //Size in BYTES of the file.
unsigned long Reserved; //Reserved. Set to zero.
unsigned long OffSet; //Offset to the data.
unsigned long headsize; //Size of rest of header. Set to 40.
unsigned long Width; //Width of bitmap in pixels.
unsigned long Height; // Height of bitmap in pixels.
unsigned int Planes; //Number of Planes. Set to 1.
unsigned int BitsPerPixel; //Number of Bits per pixels.
unsigned long Compression; //Compression. Usually set to 0.
unsigned long SizeImage; //Size in bytes of the bitmap.
unsigned long XPixelsPreMeter; //Horizontal pixels per meter.
unsigned long YPixelsPreMeter; //Vertical pixels per meter.
unsigned long ColorsUsed; //Number of colors used.
unsigned long ColorsImportant; //Number of "important" colors.
};
int ShowBMP(int x, int y, char* FileName)
{
int b,a;
BMP Obj;
unsigned char* Datas;
int in=0;
unsigned char c=0;
FILE * fp;
fp = fopen(FileName,"rb");
if(!fp){
printf("Error : Unable to open file ..");
exit(0);
}
fread(&Obj, sizeof(Obj), 1, fp);
if(Obj.BitsPerPixel!=4) // This isn't a 16 color bmp we can read;
{
fclose(fp);
printf("Error : File format not supported ..");
exit(0);
};
fseek(fp,Obj.OffSet,SEEK_SET);
Datas=(unsigned char*) calloc(Obj.Width/2+1, sizeof(unsigned char));
for(b=Obj.Height;b>=0;b--)
{
fread(Datas, sizeof(unsigned char), Obj.Width/2, fp);
c=0;
in=0;
for(a=0;a<=Obj.Width;a+=2)
{
c = (Datas[in] | 0x00) >>4;
putpixel(a+x,b+y,c);
c = (Datas[in] | 0xF0) & 0x0F;
putpixel(a+1+x,b+y,c);
in++;
}
}
free (Datas);
fclose(fp);
return 1;
}
void main()
{
int color;
int gd , gm ;
gd = …
I have searched the forum , also over internet but i didn't found any understandable method to convert float number to string , Please help Me in conversion.
void name(int a,int b,int c,int &sum,int &avg){ }
"&" mean referring a variable , this is a way by which function return more than one value.
Example is this
char arr[100],i=0;
while((arr=getchar())!='\n')
i++;
so it will take any number of character from 0 to max size until enter is not encountered
but in integer i always want a loop any specific number
like
for(i=0;i<3;i++)
scanf("%d",&arr);
but my size of array can get 100 integer more and every time i want to come in main programme to specify how much i need
I think every one got it , so please help.
Actually the question is that i want to get a int array but dont specify how much i need in programme , like in getchar function can takes 0 to max size of an array , can i do it with int .
Is there is any function through which i can get specific number of integer like we do through getchar() funtion .I AM USING TURBO C 3.0.HELP WILL BE APPRECIATED.
It is c++ not c ,You dont need format specifier in this.
#include <iostream>
#include <iomanip>
#include<stdlib>
using namespace std;
void Courses ();
void Receipt ();
void studentid ();
main ()
{
int crn1 = 0;
int crn2 = 0;
int crn3 = 0;
int studentid;
int num;
int course1 = 0;
int course2 = 0 ;
int course3 = 0 ;
double total1;
double total2;
double total3;
double healthfees = 35.00;
double finalprice;
char answer ;
Courses ();
cout <<"Enter the Students Id: ";
cin >> studentid;
cout <<"\n";
cout <<"Enter how many courses-up to 3: ";
cin >> num;
cout <<"\n";
while (num < 1 || num >= 4)
{
cout<<"Invalid number! Try again\n\n";
cout <<"Enter how many courses-up to 3: ";
cin >> num;
cout <<"\n";
}
switch (num)
{
case 3 : cout <<"Enter the 3 course numbers: ";
cin >> course1 >> course2 >> course3;
cout <<"\n";
break;
case 2 : cout <<"Enter the 2 course numbers: ";
cin >> course1 >> course2;
cout <<"\n";
break;
case 1 : cout <<"Enter 1 course number: ";
cin >> course1;
cout <<"\n";
break;
default : cout <<"Invalid number! Try again!\n\n";
system ("pause");
return 0;
}
switch (course1)
{
case 4587 : crn1 = 4;
break;
case 4599 : crn1 = 3;
break;
case 8997 : crn1 = 1;
break;
case 9696 : crn1 = 3;
}
switch (course2)
{
case 4587 : crn2 = 4;
break;
case 4599 : crn2 = 3;
break;
case 8997 : crn2 = 1;
break;
case 9696 : crn2 = 3;
}
switch …
if (crn1 + crn2 + crn3 > 7); if (answer == 'n');
These are mistakes.
similarly correct your other if statement.
Why dont you try this one
if (answer == 'y')
{
cout <<"Enter how many courses-up to 3: ";
cin >> num;
cout <<"\n";
}
After else always there is a statement and using ; tells that statement is complete specially with if dont use ; it means that if statement has no outer coverge to other statement which make it of no use.
That semicolon with if statement is a mistake remove that please when You correct the program.
You can use
else
exit(0);
for finishing the program or goto to go back .
CORRECT IT
if (answer == 'y');
{cout <<"Enter how many courses-up to 3: ";
cin >> num;
cout <<"\n"}
.
>> You cant declare function and integer name same in a program . Then how did you run the program.
Explain your problem
For calling print input and print area you need one int and two double .
Syntax will be like this
printarea(i,j,k); //Where i is taken as int j and k are taken as double
What do you mean by noisy input stream?
You havent define your class date
Class date d;
I am just guessing . Please check it.
simple Cin mean console input , By default it takes value from you keyboard and cout mean console output by default it print value on screen.Your program is very simple to understand . it take employ id , house worked and hourly rate , then it place hourly rate multiplication with house worked in grosspay and finally it print all the values.
Where is your "Date.h".
printf("%c%c",s[0],s[1]);
It will print only first two characters.
sorry it is
if(check>19)
for(i=0; i<arry_size; i++)
{
int check=rand()4%20;
if(check!=19)
nums[i] = check;
}
I dont got your point clearly. May be it is helpful to you.