This program accepts Student ID numbers, Name, and grade point average. The problem I am having is with the if else statement that compares id to studentID[x]. I have tried to compare using if(id.equals(studentID[x])) and also I have tried using if(id == (studentID[x])) as shown in the code below. I keep getting incorrect results though.
//FILE: StudentIDArray.java
import javax.swing.*; //Used for the JOption dialog boxes
import java.util.*; //Used for Scanner input
I am looking to reconcile data between SQL server and Oracle DB post the migration, I need to verify the data (rows/columns) for last 10 years, Before i start writing a Java Utility to accomplish this, My question is are there any existing libraries or API which can accomplish the same ....
I'm working on a project based on Roger Alsing's Mona Lisa evolution.
My problem seems to be that when I compare the RGB values of the target image and the randomly generated image, I don't get a representative result of how "close" the two images are.
I load the target image (a 24-bit bitmap) using:
img = ImageIO.read(new File(filePath));
I draw onto a BufferedImage with:
for(int i = 0; i < numPolys*12; i += 12){ p[(int)(i/12)].addPoint(gene[i], gene[i+1]); p[(int)(i/12)].addPoint(gene[i+2], gene[i+3]); p[(int)(i/12)].addPoint(gene[i+4], gene[i+5]); p[(int)(i/12)].addPoint(gene[i+6], gene[i+7]); Color mycol = new Color(gene[i+8], gene[i+9], gene[i+10], gene[i+11]); gf.setColor(mycol); gf.fillPolygon(p[(int)(i/12)]); }
And I compare the BufferedImage with the target image using:
for(int x = 0; x < inGene.x; ++x){ for(int y = 0; y < inGene.y; ++y){ Color mycol1 = new Color(exp.getRGB(x, y)); Color mycol2 = new Color(inImage.getRGB(x, y)); int delta = mycol1.getRed() - mycol2.getRed(); score += (delta * delta); delta = mycol1.getGreen() - mycol2.getGreen(); score += (delta * delta); delta = mycol1.getBlue() - mycol2.getBlue(); score += (delta * delta); } }
My problem is that my code runs to a certain point, where it seems no matter what happens to the image, it doesn't seem to get any closer to the target image.
I am trying some exercises on codingbat.com, and am stuck at the following program.
"Given a string, return true if it ends in "ly"."
With the following lines, if I type a print command instead of return, I get "ly". Yet if I aks to compare the result (which is "ly" as I can see with a print command) with == "ly", I get false?
What I also don't get, is that if I tye the programs in javascript, in that language the program works.
Ok I am trying to compare a string to see if all characters are unique. If there is a library for this or a better way to approach this do tell. However I find it important to understand what is going on behind the scenes. The issue is that the program counts the spaces '/0' and therefore everything will never be unique.
public class CheckUnique { private String sentence = "This will be compard"; private char[] checker; private String isUnique = "The sentence is unique"; private String notUnique = "The sentence is not unique";
what will i compare in if statemet is the 1st letter of each if i have code="a" and name="Angelina" first letter of each is "a" and "A" then in convert it to string so that i can make it uppercase but when i compare it in if statement it always go into "not x" but the ouput that im getting is x=A y=A then it always direct me into else statement.
String code = "a"; String name = "Angelina"; char c = code.charAt(0); char n = name.charAt(0);
I want to compere two element of string array by each other! eventually I want to print Yes or No in matrix . SO, I start reading data from file then split them into two parts .
File file= new File(fileName); try { inputStream = new Scanner(file); while (inputStream.hasNext()){ String data= inputStream.next(); String [] token =data.split(","); System.out.println("day"+token[0] +"embloyee name:"+ token[1]) ; } inputStream.close();
Now I want to compere each cell from token[0] by another array :
if the days are equal then I want print yes in front of the employee name if not then i want to print No..is this gone work with me as I imagine it to be or do I have to take few more steps to get my code going?
I'am trying to converting string data into xml data using xml beans and StringEscapeUtils.This is work fine but in one case it if the data contains special characters.
Code snippet -------------------- import org.apache.commons.lang3.StringEscapeUtils; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; public class ParseXMLData { public static XmlObject parseXML(String stringXML) { XmlObject xmlObject = null;
[Code] ....
success case --------------------------- i/p------<aaa><bbb>This converts string to xml</bbb></aaa> o/p---<aaa><bbb>This converts string to xml</bbb></aaa>
Failer case ----------------- i/p----<aaa><bbb>This fails if it contains < symbols</bbb></aaa> expected o/p----<aaa><bbb>This fails if it contains < symbols</bbb></aaa>
Observed that it converts < to '<' but as per xml rules, if data contains '< ' it fails. I want to convert staring and end tags to xml format and if data in b/w middle of starting and ending tags do'n need to convert it. How to do it.
A group of my classmates and I were discussing strings. We were asked, "What circumstances would you want to convert a text string to numerical data?" but we couldn't think of any answers outside of counting characters within the string for various applications.
I have a double primitive and gave it a huge value. I am curious if valueOf could ever potentially cause data loss. I tried a simple test and it seems it never loses any data:
Java Code:
public class DoubleStringTest { public static void main(String[] args) { double val = 1029.129348558634; System.out.println(val); System.out.println(String.valueOf(val)); } } mh_sh_highlight_all('java');
I'm just trying to append new employee information to a previously created file. When I type yes to add new employee and enter a string, the data does not appear in the file.
Java Code:
public class Records { public static void main(String [] args) throws IOException { Scanner input = new Scanner(System.in); FileWriter fw = new FileWriter("dbs3.java", true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter pw = new PrintWriter(bw);
I have table data I'm trying to read . However one column is populated with the word "null". I guess java does not like dealing with the word null and throws errors.
When I try a block like : if ( rsrow.getString(insCol) = "null") {
I get and error .
If I try :
cmp = rsrow.getString(insCol);If I try:If I try: if (cmp = "null") {
I get an error
If I try to use a replace function like:
System.out.println(cmp.replace("null", "0"));
Just to see if replace works I get and error.
What is the BEST way to replace this string value with something like "0" when I come across it with out jave throwing an error? I want it such that every time I come across the word "null" I can repalce it with "0".
I'm getting a Base64 encoded String of raw PDF data from a web service. I have to use this data display the PDF in a PDF viewer (I happen to be using the included 'ThinkFree PDF Viewer' since I'm working on an Android application, but the Android forum doesn't seem to get much traffic, so lets generalize and say any PDF viewer will do).
My code:
File file; FileOutputStream outputStream;
public void createFile() { try { File path = new File(getFilesDir(), "PDFs"); if (!path.exists()) { path.mkdirs();
[code]....
The error: Error opening file. It does not exist or cannot be read.
I need to get the html in string when i hit the hit the jsp in servlets basically i need to put the output of jsp in pdf file when i hit one link i need to download that data in pdf file. I am using itextpdf.
//Get the output stream for writing PDF object OutputStream outStream=pResponse.getOutputStream(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
[Code] ....
I need to convert the sample download.jsp to html so that i can parse
I have created an enumerated data type that represents months. In my program I have asked the user for the month. I hold the month entered by user into a string variable. From that string variable I'm trying to display the month using my enumerated data type. I know I can use if statements, but is there another simple way to do it?
import java.util.Scanner; public class demo { //Enum class called month that has constants in it representing months enum month{january,february,march,april,may,june, july,august,september, october,november, december};
I am writing a code in which a user inputs data as a string and that data must be verified as a valid number. A valid number is anything from 0-100. Then all valid numbers are converted into double numbers.
I am having trouble in how to write the validation part of the code.
Is it suppose to be an if, else statement? And if so how is it suppose to be validated?
I'm trying to create an algorithm that compares the first names of two people, which goes ahead and cancels similar characters and then counts the remaining characters to give a 0 if the remaining characters are even and a 1 if the remaining characters odd.
I'm working on a program with the following instructions: Write a class named Octagon that extends GeometricObject and implements the Comparable and Cloneable interfaces. Assume that all 8 sides of the octagon are of equal size. The area can be computed using the following formula
area = (2 + 4/square root of 2) * side * side
Write a program (driver) to read in a series of values from a file, display the area and perimeter, create a clone and compare the object and its clone (based on the area). In addition, your program should compare the current object (just read in) with the first object read in. The program ends when a negative number is read from the file.
My GeometricObject abstract class:
public abstract class GeometricObject { public abstract double getArea(); public abstract double getPerimeter(); }
My Octagon Class:
public class Octagon extends GeometricObject implements Comparable<Octagon> { private double side = 1.0; protected native Object clone() throws CloneNotSupportedException; public Octagon() { } public Octagon(double side) { super();
[code]....
As you can tell, I've still got a long way to go in the tester class but this is where I'm running into some difficulties.
You'll notice that in the return statement of the toString method in the Octagon class, I put a ? after the "Clone Compare:" portion of the code, what should go here. I've never worked with either the Comparable or Cloneable interfaces before.
How I should create my objects in a way that would give the following sample output.
I was writing a code to have the library books classified in name, author, area, ed, etc. I'm using NetBeans and it doesn't accuse any error. But when I run the project, it never goes right and shows the books only in one area, regarthless what I type. (The goal of the algorithm is to separate the books in areas (sciences, humanities and biological science).
I have to make a program in which users inputs a number and the program should search into a two dimensional array and print out all the values that are below the number This is my first time experimenting with 2D Arrays and how to do this program I have the array set up