I give my dataset in csv (or text) format to my program but it says "(The system cannot find the file specified)" even though the file exists.
what should I do?
here is my code:
Java Code: public class ReadCSV {
HashMap<String, Integer> authorList = new HashMap<>();
File file = new File("d:/Course/thesis/predict/whole.scv");
int authorCounter = 0;
public static void main(String[] args) {
ReadCSV obj = new ReadCSV();
My interest in Java leads me to try and print numbers from 1-100. The output should show all numbers from 1-100 and each number that is divisible by by 13 should be replaced with a string "Fuzzy".
public class Fuzzy { public static void main (String[]args){ for(int i = 0; i < 100; i++) if(i % 13==0) System.out.print(i + "fuzzy"); } }
I'm making a program that will read the file and put the numbers in a list of int arrays and names in another list of strings. In my program i created two classes. One will receive the numbers and the other will receive the names. But i only can read the numbers! How can I read everything and separate into two different lists?
try( BufferedReader br = new BufferedReader( new FileReader( jFileChooser1.getSelectedFile().getAbsolutePath() ) ) ) { hist = new Historic();//Will recieve the array of numbers. while( br.ready() ) { int line[] = new int[ 7 ];
This application is supposed to allow a user to enter the names an phone numbers of up to 20 friends, until the user enters "zzz" or 20 names. Then the console is supposed to display the names and have the user enter a name to get the phone number. Here's my code:
import java.util.Scanner; public class PhoneBook{ public static void main(String[] args){ String name; int phoneNumber; final int nameAmount=20;
[Code] ....
I can't seem to get it correct, every time I correct a compiler error, another set of them appear.
Barbara is opening a book store, and she needs an effective, efficient, object-oriented program to keep track of her inventory. Barbara would like to maintain the following information about the books she sells: title, author, price, number in stock, and category. She categorizes her books into fiction, nonfiction and children’s books, because she has a separate room in her store for each category. Each book also needs an inventory number, and Barbara would like these numbers to start with 1000. She also needs to be able to keep track of the total number of books in inventory.
Barbara often facilitate her customers find books, and the program needs search capabilities to do this. Keeping an accurate inventory count of each book in stock is critical; both for accounting purposes and so she will know when to reorder. Barbara expects to have at most 2,000 differet books in her store.Barbara is very organized, and would like a nice menu, from which she can make choices that will enable her to do the following:
Add a new book to inventory This adds a new Book object (title, author, etc) into inventory It does not increase the number in stock of an existing book Search by title Search by author Search by inventory number Search by category Print out all info for all books This is the only output that should be on the command line
Please hard code the following book info into your program, so Barbara has some test data avaiable to test your program:
title: Crime and Punishment; author: Dostoevsky; price: 39.95; number in stock: 5; category: fiction title: Brothers Karamazov; author: Dostoevsky; price 34.50; number in stock: 3; category: fiction title: Java; author: Liang; price: 59.29; number in stock: 12; category: non-fiction title: Java, author: Horstmann; price: 14.33; number in stock: 4; category: non-fiction title: The Lion, the Witch and the Wardrobe; author: Lewis; price: 12.50; number in stock: 3; category: childrens
Here is my code so far. The first one is the "Blueprint" and the second one is the main.
public class Book { private String title; private String author; private double price; private int stockNumber; private String category; private int inventoryNumber =1000; private static int numberOfBooks = 0; public Book(String theTitle, String theAuthor, double thePrice, int theStockNumber, String theCategory)
I'm trying to pull the authors from this Json object but I'm having issues trying to pull the author only, I'm only able to get a huge string which is a valid JSON object i tested it in [URL]
I can't figure out why my code doesn't work. My task is to replace for example ä=>ae, using this method String.charAt(int index). So here is my code:
public class pich { public static void main(String[] args) { String text = "Die süße Hündin Leica läuft in die Höhle des fülligen Bären "+ "Iliyan (ein Übergrößenträger), der sie zum Teekränzchen eingeladen hat."+ " An ihrem Öhrchen trägt sie modisch eine Ähre."; String textOhneUmlaute = "";
[Code] ....
when I launch my code I get the same String and nothing has changed
Basically, I am trying to write a method that will take a string, a target, and a replacement (a replacement function like string.replace). I want it to replace all instances of target with replacement EXCEPT for instances that occur within single or double quotes.
Example input / output:
this "Wont" be " replaced, be"
call: replace(theString, "replaced", "narf") and replace(theString, "be", "rafn")
I have a 2D arraylist, named as adjLists, which contains arraylists, containing values like these. Each two values are a "pair" and each third is a "flag" for the pair.
I use code above to search for specified value pairs in these lists. vertexnum is the number of "sub arraylists" in adjLists.
for (int l = 0; l < vertexnum; l++) { if (adjLists.get(l).get(0) == p.x && adjLists.get(l).get(1) == p.y) { for (int h = 0; h < adjLists.get(l).size(); h += 3) { for (int g = 0; g < vertexnum; g++) { if ((vertexSprite[g].getX() + vertexSprite[g].getWidth() / 2) == adjLists.get(l).get(h)
[Code] ....
This code is to search exact values and replace their flag in every occurences. It can not find all the occurences of the values/pair in the lists, it replaces flag value only a few time. Value of score should be incremented with plus 1 after each found occurence, but this code increments it more than the number of matches.
I'm trying to figure out the correct way to replace number into letter. In this case, I need two steps.
First, convert letter to number. Second, restore number to word.
Words list: a = 1, b = 2, f = 6 and k = 11.
I have word: "baafk"
So, for first step, it must be: "211611"
Number "211611" must be converted to "baafk".
But, I failed at second step.
Code I've tried:
public class str_number { public static void main(String[] args){ String word = "baafk"; String number = word.replace("a", "1").replace("b","2").replace("f","6").replace("k","11"); System.out.println(word);
[Code] .....
Result for converting to number: baafk = 211611 But, result for converting above number to letter: 211611 = bkfk
What do I miss here?
How to distinguish if 11 is for "aa" and for "k"? D
I was reading a book and came across this while loop.
public class Powers { public static void main (String [] args){ int e; int result; for(int i = 0; i < 10; i++){
[Code] .....
This loop presents the following (I'm sure it's not necessary):
2 to the 0 power is 1 2 to the 1 power is 2 2 to the 2 power is 4 2 to the 3 power is 8 2 to the 4 power is 16 2 to the 5 power is 32 2 to the 6 power is 64 2 to the 7 power is 128 2 to the 8 power is 256 2 to the 9 power is 512
I am just having a difficult time understand and grasping this concept. My main issue is result *=2; this is making it very difficult to understand. How is result being replace if it only equals to 1.
I'm trying to figure out the correct way to replace number into letter. In this case, I need two steps.
First, convert letter to number. Second, restore number to word.
Words list: a = 1, b = 2, f = 6 and k = 11.
I have word: "baafk"
So, for first step, it must be: "211611"
Number "211611" must be converted to "baafk".
But, I failed at second step.
Code I've tried:
public class str_number { public static void main(String[] args){ String word = "baafk"; String number = word.replace("a", "1").replace("b","2").replace("f","6").replace("k","11"); System.out.println(word);
[Code] ...
Result for converting to number: baafk = 211611
But, result for converting above number to letter: 211611 = bkfk
How to distinguish if 11 is for "aa" and for "k"? Do you have any solutions or other ways for this case?
I am trying to custom graphic class..,My task is to replace the specific area color of the image when i select the area & pick the color..,If i choose the hand / body of the T-shirts means the color can change by the user..,
I am wondering if there is something similar to the "Find and Replace" action, that we use in applications like Eclipse and MS Word, that is actually built into the Java API so we can use it in our code, mainly for method names?
For example, right now I have these couple of lines
that does one operation for a side of Rubik's cube. However, all other sides of the cube can use these same exact code with the exception of the 2nd word, ie the position, in each method.
So for example, another side would do something, like, lets say
The reason why I ask this is because this would DRASTICALLY shrink the size my code, rather than have to create separate methods for each operation. Now I know there is a Find and Replace feature for Strings, but I am not sure about method names...
My question is related to combo boxes. A combo box in general is a text field with a dropdown list. I would want to know if we can replace hthe dropdown List by an other component, for example a JTable component.
I want to do a simple search and replace regular expression of lines. I am very unfamilar with Java regular expressions, and I'm not sure how to do something as simple as what I want to do. I have lines that look like this...
The reason I want to use regular expressions is because I want to use the replaceAll method of the java.lang.String object. If I use replace I have to convert my strings into char arrays, and my code becomes bulky.
How to replace correct letter with the blanks in the program. Last method in program used to print correct letters.
import java.util.*; import java.io.*; public class Hangman { public static Scanner keyboard; public static final int MAXSIZE = 15000; public static final int NUM_GUESS = 8; public static final int WORD_LENGTH = 20;
I am creating a simple code in Java that replaces all tabs the user inputs with '*'. However, I am doing something wrong and I am not sure what. Here is what I have so far in Eclipse..
import java.util.Scanner; public class ReplacingTabs { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = ""; String s2 = "";
[Code] .....
There is an error with the s2 in the line String s2 = s.replace(' ','*');
I think I need to add String s2 to the loop but I am not sure how..
My friends and me are trying to make online Test taking system. We got a very basic doubt.
We have developed classes and relationship between classes for example : Online Test Taking system will have admin and student class. And Admin will have list of students.. etc.
But question troubled me was: if we use database to store all data for example student details then I can perform all sorts of operations writing sql query and store result in some other database then what is the need of "ArrayList<Student> field in Admin".??
Question is: We can put everything in database and manipulate using database(sql) functions to manipulate it.Then what is the need of Arraylist of anything which is just used to store object details for example student details....??