Featured Editorial

Latest Topics

Member Avatar

I have a problem that regarding with my projects. I need to create a bleuprint of an urban planning and I manage to print all the buildings that are required usning array. My problem right now is how I am going to print the roads. (<>^v, 1, -1, Road (-1 = no maximum, ^, v, <, >, indicates direction of road, <> or ^v, indicates this road is two way left right or up down, follow order <>^v)) Here the palnning: C C ^ V S S C C > >^ >v > >^v S S C C < <^ …

Member Avatar
+0 forum 1
Member Avatar
Reusable Code Snippet Make a given number odd or even

There are times when you need to make sure your counter starts at an odd or even number. Even is pretty simple - `counter = counter + modulus(counter)`. If counter is even it stays, if it's odd it gets incremented by 1. Odd is a bit more complicated - `counter = counter + modulus(counter + 1)`, If counter is odd it stays, if it's even it gets incremented by 1. if you're in danger of counter being the max value you can always subtract instead. These basic algorithms should work for any language that has a modulus operator/function. I've included …

Member Avatar
+2 forum 4
Member Avatar

Hello Everyone!, I am currently a freshman at MATC(Milwaukee Area Techinal College) I am at the one Downtown in Milwaukee, and I am taking a class called Intro To Oriented Computer Programming(which is learning and coding the Program Java, and I have been seeing a tutor, but I cannnot figure out for the life of me as to how to do this assignment and here are the instrcutions for it........ ****Bester is a dice game where players try to play the odds against each other. Each player rolls five die for up to five rolls. The total value of all …

Member Avatar
+0 forum 1
Member Avatar

public class HashedClass{   int ticketNumber; // keyfield string purchaserName;   Hashtable hashtable = new Hashtable();   insert();   fetch();   delete();   update();   } I started a pseudocode above, but I know it needs more work. Are there any resources that can help guide me to implementing my own java hashed perfect algorithm? I know that you have to use the direct hashed four basic operation for each four methods, right? But how can I do that based on pseudocode?

Member Avatar
+0 forum 3
Member Avatar

Create a Project name Banking which will have the following classes with the given instance variables and the methods Create a class Account with first name , last name, address , phone number, balance (instance variables) Withdrawal and deposit methods Create checking account class extending the account class, Having additional instance variables monthly fees, over draft limit(OD), over draft active, overdraft fees Overriding the withdrawal and deposit methods Withdrawal method should check the over draft active or not if yes then should check the balance with the withdrawal amount and then perform the withdrawal, if withdrawal request is within the …

Member Avatar
+0 forum 1
Member Avatar

Hello, I am writing a Java program where the first JFrame has choices for number of shapes, width, height and the type of shape (oval, rectangle or both) and a button is clicked that opens up another JFrame where the shapes are drawn with a time delay until the number of shapes equals the user input. Everything works fine except the JButton from the first JFrame is displayed at the top left corner of the second JFrame when the JButton on the first frame is pressed. Any idea how to fix this issue? import javax.swing.JPanel; import javax.swing.Timer; import javax.swing.JOptionPane; import …

Member Avatar
+0 forum 6
Member Avatar

Hi all, I have an application which saves data (books details like book title, author and location) to a mySql db and performs CRUD operations. I thought I'd use hibernate to take care of the ORM side of things and everything was OK when it came to create a record, but for RUD operations I had an issue. If I'm a user, I'm likely to be willing to find a book by its author, title or location, certainly not by its ID and yet as far as I can see, hibernate uses IDs for these kind of operations. I dug …

+0 forum 0
Member Avatar

My problem is setting the size of the JButton. I want it to be a little button centered below the "Hello World" JLabel field (as it is now it spans the full width of the JFrame). I am unsure what is causing the setPreferredsize to be ignored. I am an ameture/novice Java Developer and appriciate any help and all help. My code is below error free: /* Author: Ashley * This program will display a basic JFrame, JLabel, and JButton. * The JLabel will display "Hello World and the JButton will close the program */ import java.awt.*; import java.awt.event.*; import …

Member Avatar
+0 forum 4
Member Avatar

Now I am making my pos software client - server based software. I am using java derby as the database. On the local host I am running the program successfully. But on the remote server I face an exception. First I tell you, how I am connecting to the remote server below: I connect my laptop to my pc through LAN Cable. I am using my laptop as client and my desktop PC as Server. On my Server I run the following command to start the Derby Server: C:\Program Files (x86)\Java\jdk1.7.0_79\db\lib> java -jar derbyrun.jar start server Above mentioned command starts …

Member Avatar
+0 forum 7
Member Avatar

Hi! I have made a POS Sotware. I have used only one JFrame as Main/Home Screen of the software and used JDialogs for all other screens. In this post I have concern with the 2 screens; Home Screen(which is a Jframe) and Sales Screen(which is a JDialog). As Home Screen appears I instantiate an instance of the Sales Screen in the constructor of Home Screen as : Sale sale = new Sale(); And on Pressing a Button on Home Screen I called : sale.visible(true); In the WindowOpened Event of the "Sale" Screen I load the products data from database and …

Member Avatar
+0 forum 14
Member Avatar

I having been trying to change the font size and textposition of a textfield but I have not had any luck. I am trying to change the font size of a text field. I would like the font that is typed in the text field to be bigger and bolded. I have tried this, but it does does not work: [CODE] Font font1 = new Font("SansSerif", Font.BOLD, 20); JTextField textfield = new JTextField (); textfield.setFont(font1); [/CODE] Also, I want the texted to be centered in the textfield. I have used this: [CODE] textfield.setHorizontalTextPostion.CENTER textfield.setVerticalTextPostion.CENTER [/CODE] Thank you for your help …

Member Avatar
+0 forum 5
Member Avatar

I am trying to create a method that will count number of zeros in a statement/numbers (numOfZero), that a string as input and returns the number of occurrence of ‘0’ in the string. And if there is no zero it should return zero. I have used String.length() and String.CharAt(int index). but getting some errors. Any help?

Member Avatar
+0 forum 2
Member Avatar

T=4 square root a+e to the power x and the hole ÷ by sin 60

Member Avatar
-1 forum 1
Member Avatar

When posting code, I get error > begin a line with 4 spaces in a row (or one tab), preceded by a blank line. 4+ spaces or tabs may not be used anywhere else.

Member Avatar
+0 forum 10
Member Avatar

Ask the user to enter - Name - ID - File Name Randomly choose five grades for that person from 1 to 100 and store them in an array that can hold five integers. Then output the name, ID, and those five grades to the screen and save the output into the specified file. The file will look like: --------------------------------- 220181234 Ahmed Ihab Grade 1 : 60 Grade 2 : 75 Grade 3 : 30 Grade 4 : 96 Grade 5 : 63 ---------------------------------- Note: Write the File using Buffered Writer

Member Avatar
+0 forum 2
Member Avatar

Ask the user to enter - Name - ID - File Name Randomly choose five grades for that person from 1 to 100 and store them in an array that can hold five integers. Then output the name, ID, and those five grades to the screen and save the output into the specified file. The file will look like: --------------------------------- 220181234 Ahmed Ihab Grade 1 : 60 Grade 2 : 75 Grade 3 : 30 Grade 4 : 96 Grade 5 : 63 ---------------------------------- Note: Write the File using BufferedWriter

Member Avatar
+0 forum 1
Member Avatar

Hi guys, I'm a little stuck with something here. Basically I have a a method which, given a List of Students will have to filter out those who are younger than 60yrs old and should return a List of Students who are over 60yrs old but I want this to be a list of Optionals rather than just a List of Students. THe difficulty is that I can't find a way to return a list of optionals like List<Optional<Student>>. I can return an optional if I use things like findFirst() or findAny() `return studentList.stream().filter(x -> x.getAge() > 60).findAny();` or i …

Member Avatar
+0 forum 4
Member Avatar

Hi guys, I am having an issue finding duplicates in an arrayList. Here is some code studentRecords.add(new Student("Jo", "Pip", "JP000", LocalDate.of(1999,9,23), Sex.FEMALE)); studentRecords.add(new Student("Tara", "Bot", "TB345", LocalDate.of(1991,9,1), Sex.FEMALE)); studentRecords.add(new Student("Mara", "Lewart", "ML456", LocalDate.of(1988,5,23), Sex.FEMALE)); studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE)); studentRecords.add(new Student("Frank", "Boia", "FB300", LocalDate.of(2001,8,13), Sex.MALE)); studentRecords.add(new Student("Anna", "Clarke", "AC010", LocalDate.of(1999,1,1), Sex.FEMALE)); studentRecords.add(new Student("Jo", "Pip", "JP000", LocalDate.of(1999,9,23), Sex.FEMALE)); This is the list of student records stored in an ArrayList. I have to make sure that I identify the duplicates and store the duplicates in another arrayList, duplicateRecords for the sake of argument. Now, the first thing I tried was to …

Member Avatar
+1 forum 4
Member Avatar

write a program to convert celsius to fahrenheit in c using do loop

Member Avatar
+0 forum 1
Member Avatar

I new in learning Object Oriented Programming... I face a problem that how to do this question for loop and if.... hopefully can get some help in this website...` this question is need to do from the previos question.. this is java need to do the question using NetBeans.IDE.. question:(at the link file) VehicleApp.java: package vehicleapp; /** * * @author asus */ public class VehicleApp { /** * @param args the command line arguments */ public static void main(String[] args) { Vehicle car; car = new Vehicle("car", "manual", "electric"); System.out.println("Accelerate: Current Speed = " + car.accelerate()); car.brake(); System.out.println("Brake: Current Speed …

Member Avatar
+0 forum 1
Member Avatar

I'm doing an assignment for a class and I can't figure out what I'm doing wrong to keep getting the "illegal start of expression" error. Any help would be appreciated. public class Overloading { public static void main(String[] args) { public static int max(int num1, int num2) { if (num1 > num2) return num1; else return num2; } public static double max(double num1, double num2) { if (num1 > num2) return num1; else return num2; } public static int max(double num1, double num2) { if (num1 > num2) return num1; else return num2; { public static double max(int num1, double …

Member Avatar
+0 forum 5
Member Avatar

![71923951_2309021662681505_5309298929043505152_n.jpg](/attachments/large/4/1849a45b2f18751c208bb45861be2f10.jpg)

Member Avatar
+1 forum 3
Member Avatar

At the risk of making a total fool of myself... I got very excited when I discovered that Java's "only opaque rectangular windows" limitation has been removed. Full release is intended for Java 7, but working methods can be accessed thru com.sun.awt.AWTUtilities in recent releases of Java 6 (I'm using update 20). I put together this little demo that adds some animation to the effects to give a hint of the potential. It runs for me under Windows 7 Home Premium; I just had to adjust Eclipse's compiler settings to warn rather then error for access rule violations. I'd be …

Member Avatar
+2 forum 9
Member Avatar

H! I am writing a java proram in which I need to generate and read barcodes to and from .PNG images. I used barcode4j-2.jar library to generate barcodes and write them to PNG image. I did this successfully. But I faced an error during reading that generated barcode from the image. I used "OnBarcode.BarcodeReader.jar" library to read the barcode but it give s me folloiwng error: java.lang.NoClassDefFoundError: com/sun/media/jai/codec/SeekableStream at a.a.b.a.a(a.java) at a.a.d.a(d.java) at a.a.d.a(d.java) at a.a.d.b(d.java) at a.a.d.a(d.java) at a.a.d.e(d.java) at a.a.d.c(d.java) at a.a.d.a(d.java) at a.a.d.a(d.java) at OnBarcode.Barcode.BarcodeScanner.BarcodeScanner.Scan(BarcodeScanner.java) I am pasting the code here: public void ReadBarcodeFromImage() throws FileNotFoundException,IOException // …

Member Avatar
+0 forum 2
Member Avatar

The company sells the coffee in 2-lb bags only, and the price of a single 2-lb bag is $5.50. When a customer places an order, the company ships the order in boxes. The boxes come in three sizes: the large box holds 20 bags of 2 lb, the medium 10 bags, and the small 5 bags. The cost of a large box is $1.80; a medium box, $1.00; and a small box, $0.60. The order is shipped in the least expensive manner. For example, the order of 52 bags will be shipped in four boxes: two large, one medium, and …

Member Avatar
-1 forum 1
Member Avatar

Hi, I'm wondering if it's possible to have a desktop app with a database online? Can you give me an example? :P

Member Avatar
+0 forum 6
Member Avatar

The question is compPickInt will now be a 0,1, or 2. Use an ‘if-else if’ structure to convert the numbers to a char variable with the value of R or S or P and Prompt the user to enter R for Rock, S for Scissors or P for Paper. Use this java code to store the user’s choice as a char variable:char userPick = s.next().charAt(0). I can't do the convertion int to char and the display is wrong like that; I have my pick behind my back What is your pick? R, S, P P My pick = 2 Your …

+0 forum 0
Member Avatar

import java.util.Scanner; import java.util.Random; class Lottery { // MISSING CODE } public class LotteryDemo { public static void main(String[] args) { int[] userPicks = new int[5]; int matching; // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // Create a Lottery object. Lottery lotto = new Lottery(); // Get the user's picks. for (int digit = 1; digit <= 5; digit++) { System.out.print("Enter digit " + digit + ": "); userPicks[digit-1] = keyboard.nextInt(); while (userPicks[digit-1] < 0 || userPicks[digit-1] > 9) { System.out.print("ERROR. Enter a single digit (0 - 9): "); userPicks[digit-1] = keyboard.nextInt(); } } …

Member Avatar
+0 forum 3
Member Avatar

Hey, I'm trying to open a web page inside my newest android app. (I'm following this guide...) [url]http://developer.android.com/reference/android/webkit/WebView.html[/url] My goal with the app is to open up the web page every time it gets opened, but the web pages need to open within the activity. With the code below, it does open the web page, but inside the browser app, how can I open the web page inside my own app? What specific changes do I need to make on my .java activity file, and my .xml layout file? [CODE]// part of .java activity file WebView webview = new WebView(this); …

Member Avatar
+0 forum 2
Member Avatar

Are there any differencies between these two code ? if (!a.equals("")) { editDate.setText(a) } and if (a!="") { editDate.setText(a) }

Member Avatar
+1 forum 3

The End.