|
No mater how you ask, it is unlikely anyone will write the code for you.
This is not a difficult assignment. Use Sysytem.in to read from the console and System.out to write to it.
An array is simple enough to define:
String dataArray[][] = new String[2][4];
Now you can do your homework and get the warm glow of a job well done.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|
|
help me write the codes
What do you have got by now? Try it, when you can't get it right - come back and ask specific.
As we do not want do do your homework - that wouldn't help you in any way - we wont post codes. But we are pretty clever in giving unmistakable hints.
regards,
Torsten
I never finish anyth...
|
|
|
|
|
If you could show us what you've done, then we can help you to complete the assignment. Don't worry it's right or wrong, try it first. That makes a difference. Good luck!
I appreciate your help all the time...
CodingLover
|
|
|
|
|
import java.util.Scanner;
//import java.lang.String;
public class Main {
public static int n;
//public static String names;
//private static String[] nameS;
//private static String[] nameS;
/**
* @param args the command line arguments
*/
public static void main(String[] args/*,String[] nameS*/) {
Scanner in=new Scanner(System.in);
int Da=0;
int num []=new int[n];
//int x=0;
System.out.printf("%s\n","Enter the Number of student taking This Couse");
n=in.nextInt();
String name[]=new String [n];
System.out.printf("%s %s \n", "index","value");
for (; Da < name.length; Da++ )/*Da 4 Display array*/ {
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
System.out.println("Enter the names of the student");
String names;
names=in.nextLine();
name[n] = new String(names);
for (; Da < name.length; Da++ ){
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
}
}
i can not input the names into the array i created
pls help me
|
|
|
|
|
Do NOT set variable names with capital letter (see "int Da"). Names starting with capital letter are objects.
And do use an own counter for each loop. Otherwise you're in big trouble faster than you can imagine (might have happen here already..)
for (int iCount=0; iCount < name.length; iCount++ ) {
System.out.printf( "%5d\t%8d\n", iCount, name[iCount] );
}
Other points:
- i see a member "n" declared right on top. Where is it initialized? Do not make it "public static" - thats bad style. Set it "private final".
- use empty lines to give structure to your code. It stays readable and you in control. Also set some comments - just to tell yourself what is supposed to happen.
And finally your question:
You are not in a loop while entering the names. I suggest to take id and name of the student one at a time. And think of a object "student". It would make your task much easier.
regards
Torsten
I never finish anyth...
|
|
|
|
|
import java.util.Scanner;
//import java.lang.String;
public class Main {
public static int n;
//public static String names;
//private static String[] nameS;
//private static String[] nameS;
/**
* @param args the command line arguments
*/
public static void main(String[] args/*,String[] nameS*/) {
Scanner in=new Scanner(System.in);
int Da=0;
int num []=new int[n];
//int x=0;
System.out.printf("%s\n","Enter the Number of student taking This Couse");
n=in.nextInt();
String name[]=new String [n];
System.out.printf("%s %s \n", "index","value");
for (; Da < name.length; Da++ )/*Da 4 Display array*/ {
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
System.out.println("Enter the names of the student");
String names;
names=in.nextLine();
name[n] = new String(names);
for (; Da < name.length; Da++ ){
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
}
}
i can not input the names into the array i created
pls help me
|
|
|
|
|
First, please put your code between <pre> and </pre> tags so it's easier to read.
Next, try stepping through your for loops. It looks to me like you need a loop to cycle n times and ask for a name[i] each time.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
pls can u do that loop for me
|
|
|
|
|
I'm going to pretend I didn't see that question.
Try it yourself and ask specific questions if you have trouble. I have my own homework to do.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Firstly, LIQUID NITROGEN.
Secondly, a for loop.
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
You forgot about bacon.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|
|
Bacon???
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
|
hello every one
i am new to web services and i have develop web service client i netbeans using wsdl and it work will
but now i want to develop web services client without knowing the wsdl i just now the link of the web service like: aaaa.php
can i do it because i search but i did not find any results
|
|
|
|
|
|
thanks is what you attach example
can you guide me to tutorial , actually the web service is public i did not implement it
its news page and i want to read its content and search through it
modified on Wednesday, December 1, 2010 10:29 AM
|
|
|
|
|
also the page have feeds and i know the xml version o the web page but i do not know the wsdl
i hop any one can help
|
|
|
|
|
pleas i need help
|
|
|
|
|
Hi everybody
I want to develop a fuzzy expert system but I don't know what to use
Do you recommend jFuzzylogic (Eclipse plug-in) or Matlab or an expert system shell like (FuzzyCLIPS or JESS)?
I prefer the easiest and highly supported one.
Thank you in advance and sorry if this is not the suitable section
|
|
|
|
|
YMMV, but I developed my own, first in C some 15+ years ago, then updated parts of it in F#[^].
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Ive used drools before; its easy to understand and implement.
|
|
|
|
|
Hi all,
I'm having an issue with PDFBox (1.3.1) - I'm using a PDF with AcroForms to basically pull off a 'mail merge'. I am successfully populating the fields with data, but what I want to do now is 'render it down' or 'flatten' it. I don't want these fields to be editable in the final result. (not entirely sure I'm communicating my intention clearly here, let me know if clarification is needed)
I've found this post that says to "remove all fields from [the] acroform". I've tried this in a number of ways:
pdfAcroForm.getFields().clear();
and...
pdfAcroForm.setFields(new ArrayList());
and...
Iterator<PDField> fields = pdfAcroForm.getFields().iterator();
while (fields.hasNext())
{
PDField field = (PDField)fields.next();
field.setAcroForm(null);
}
and variations thereof...
while typing this I thought to try:
pdfAcroForm.setFields(new COSArrayList());
maybe that will fix it?
Anyway, does anyone know how to do this? I have this niggling feeling that it's a language barrier (I'm a native C# speaker). I also have a niggling feeling that the aforementioned article is a big red herring that's taken me down the road to the dark side...
Any help would be MUCH appreciated
|
|
|
|
|
[Caveat - I am not familiar with API you are using]
You should not need to remove the form fields. The pdf document allows itself to be locked, once locked the fields become ineditable.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|
|
hi all,
I'm working on a program that suppose to read data from a text file and then creates a linked list and outputs the data sorted by last name.
But I'm getting the following errors:
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
at mainStudnetProg.createStudentList(mainStudnetProg.java:36)
at mainStudnetProg.main(mainStudnetProg.java:15)
Where is the problem?!
main
import java.io.*;
import java.util.*;
public class mainStudnetProg
{
public static void main(String[] args)
{
StudentList studentList = new StudentList();
try
{
Scanner infile = new Scanner(new FileReader("C:\\studentInfo.txt"));
createStudentList(infile, studentList);
}
catch (FileNotFoundException fnfe)
{
System.out.println(fnfe.toString());
}
}
public static void createStudentList(Scanner infile, StudentList studentList)
{
String fName;
String lName;
int id;
Student newStudent;
while (infile.hasNext())
{
fName = infile.nextLine();
lName = infile.nextLine();
id = infile.nextInt();
infile.nextLine();
newStudent = new Student();
newStudent.setStudentInfo(fName, lName, id);
studentList.insertFirst(newStudent);
}
}
}
modified on Friday, November 26, 2010 10:59 PM
|
|
|
|
|
Without copying the code into eclipse:
No line found
at java.util.Scanner.nextLine
public static void createStudentList(Scanner infile, StudentList studentList)
{
String fName;
String lName;
int id;
Student newStudent;
while (infile.hasNext())
{
fName = infile.nextLine();
lName = infile.nextLine();
id = infile.nextInt();
infile.nextLine();
newStudent = new Student();
newStudent.setStudentInfo(fName, lName, id);
studentList.insertFirst(newStudent);
}
}
This method is the only position where "nextLine" is used.
The 3. "nexLine" seems strange to me - you do not handle any replies there. So why do you read the next line?
regards
Torsten
I never finish anyth...
|
|
|
|