Featured Editorial

Latest Topics

Hi All i am having a python code i have to convert this to java i have placed the code below import boto3 import sys import re import json def get_kv_map(file_name): with open(file_name, 'rb') as file: img_test = file.read() bytes_test = bytearray(img_test) print('Image loaded', file_name) # process using image bytes client = boto3.client('textract') response = client.analyze_document(Document={'Bytes': bytes_test}, FeatureTypes=['FORMS']) # Get the text blocks blocks=response['Blocks'] # get key and value maps key_map = {} value_map = {} block_map = {} for block in blocks: block_id = block['Id'] block_map[block_id] = block if block['BlockType'] == "KEY_VALUE_SET": if 'KEY' in block['EntityTypes']: key_map[block_id] = block …

Member Avatar
Member Avatar
+0 forum 1

Hi all, I'm having some issues with the Scanner not waiting for input from the keyboard. The first method processChoice takes the userChoice and the idea is that in the switch statement there is a call to a method getUserInputForProcessing that takes the action and there scanner takes an input but it's not passing the control to the keyboard, it goes directly to the Exception because nextLine is empty, not entirely sure why. Is that because it's inside a switch statement? public void processChoice(int userChoice, BookManager bookManager) { switch(userChoice) { case 0: System.out.println("Goodbye."); System.exit(0); break; case 1: System.out.println("You chose READ"); …

Member Avatar
Member Avatar
+0 forum 5

hi, In my android studio build gradle is failed i dont know how so then i check the log and i saw this error Error:Could not find method compile() for arguments [com.android.support:recyclerview-v7:25.3.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager then i check it but android support respository is already installed version 47.0.0 i restart android studio but it shows same error how i solve this error from android studio please help me to solve this problem?

Member Avatar
Member Avatar
+0 forum 2

What are all num referring to ? class Sample { int num; void method() { num = 1; int num = num = 2; num = 3; } }

Member Avatar
Member Avatar
+0 forum 4

# Find minimum integer coefficients for a chemical reaction like # A * NaOH + B * H2SO4 -> C * Na2SO4 + D * H20 import sympy import re # match a single element and optional count, like Na2 ELEMENT_CLAUSE = re.compile("([A-Z][a-z]?)([0-9]*)") def parse_compound(compound): """ Given a chemical compound like Na2SO4, return a dict of element counts like {"Na":2, "S":1, "O":4} """ assert "(" not in compound, "This parser doesn't grok subclauses" return {el: (int(num) if num else 1) for el, num in ELEMENT_CLAUSE.findall(compound)} def main(): print("\nPlease enter left-hand list of compounds, separated by spaces:") lhs_strings = input().split() lhs_compounds …

Member Avatar
Member Avatar
+0 forum 2

Is there a way to solve for a system of multiple equations with multiple variables and variables on both sides in java Lets say im given three (or more) equations in an array list or array like so... 4A=1C 10A=2D 2B=2C+1D and im allowed to set one variable equal to 1 (lets say A) is there a java function or quick/simple aproach to get the values of each variable as whole numbers. (please help)

Member Avatar
Member Avatar
+0 forum 3

How can I minify my code in here, I am giving each 23 total imageview a eventhandler. code works, but I like to make the code shorter. I tried to use for loops to shorten the code. here is a example what I tried to do: for (int i = 0 ; i < imgArrayList.size() ; i++) { imgArrayList.get(i).setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { selectedTile = i; } }); } but it can't because, the "i" inside the handle method is final. I can't pass the "i" inside the handle method. my goal is, that a specific …

Member Avatar
Member Avatar
+1 forum 4

when i am trying to insert date into the datefield of the oracle then date value are stored in to database but each date value are same like DOB 01-JAN-70 01-JAN-70 01-JAN-70 public class practicdate { JDateChooser dateChooser,dateChooser1; practicdate(){ dateChooser = new JDateChooser(); dateChooser.setBounds(200, 200, 150, 20); getContentPane().add(dateChooser); public void actionPerformed(ActionEvent e) { java.util.Date utilDate=(java.util.Date) dateChooser.getDate(); java.sql.Date sqlDate=new java.sql.Date(utilDate.getDate()); try { java.sql.PreparedStatement ps=con.prepareStatement("insert into examdate values(?)"); ps.setDate(1,new java.sql.Date(sqlDate.getDate())); ps.executeUpdate(); ps.close(); con.close(); }

Member Avatar
Member Avatar
+0 forum 1

package de.extrema.java; import java.util.Scanner; public class Pogramm { public static void main(String arrg[]) { try (Scanner scanner = new Scanner(System.in)) { double a , b , r , A , h; int number2; int number; System.out.println("Körper: "); System.out.println("Deine Wahl: "); number = scanner.nextInt(); number2 = scanner.nextInt(); switch(number) { case 1:{ switch(number) { System.out.println("Viereck: 1 Kreis: 2 Dreieck: 3 Trapez: 4 "); case 1:{ System.out.println("a: "); a = scanner.nextDouble(); System.out.println("b(a): "); b = scanner.nextDouble(); A = a * b; System.out.println("Fläche des Vierecks= " + A); break; } case 2:{ System.out.println("r: "); r = scanner.nextDouble(); A = Math.PI * r * r; …

Member Avatar
Member Avatar
+0 forum 5

I'm writing a VERY simple clock to run on an old tablet using Android Studio - it displays the current time and day (I'm retired and regularly forget what day it is). I want to add the first calendar event for the current day to the display so it goes something like: 7.30 Tuesday 10.30 Discussion Group Like a lot of functions in Andriod, doing something really simple still means digging into all sorts additional layers of code, plug-ins, permissions and so on and I haven't been able to find a worked example of how I read the calendar (on …

Member Avatar
Member Avatar
+0 forum 1

Hi. I was wondering if anyone could help me with checking for a valid move in Othello. I was thinking about hard=coding everything but that takes too long. this is what i have so far: 1. Check which direction is valid (adjacent piece is different from piece being placed) 2. Go in that direction(s) and if: 1. hit the end, or hit a empty space return false 2. hit another piece, keep going 3. hit my own piece, stop

Member Avatar
Member Avatar
+0 forum 9

1/Write a TeachArithmeticFrame class that teaches children arithmetic. The frame uses a JLabel for a problem and a JTextField for the user answer. When the user presses the Enter key (while the JTextField object is active) or clicks the OK button, display a message stating whether the user’s answer is correct. When the Next button is clicked, display a new problem. The numbers are limited to two digits. Consider using a larger font for the JLabel and JTextField text. You can change the color of text by calling the setForeground method, for example. questionLbl.setForeground(Color.RED); 2/Extend the TeachArithmeticFrame class so that …

Member Avatar
Member Avatar
+0 forum 1

Help me this everyone.I don't know where to start.

Member Avatar
Member Avatar
+0 forum 1

# Class 1 # import java.awt.Canvas; import java.awt.Color; import java.awt.image.BufferStrategy; import java.awt.Graphics; import java.lang.Runnable; import java.lang.Thread; import javax.swing.JFrame; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.IOException; public class Game extends JFrame implements Runnable{ private Canvas canvas = new Canvas(); private RenderHandler renderer; private BufferedImage testImage; private Rectangle testRectangle = new Rectangle(30, 90, 100, 100); public Game() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(0,0, 1000, 800); setLocationRelativeTo(null); add(canvas); setVisible(true); canvas.createBufferStrategy(3); renderer = new RenderHandler(getWidth(), getHeight()); BufferedImage testImage = loadImage("Grass.jpg"); testRectangle.generateGraphics(12234); } private BufferedImage loadImage(String path){ try{ BufferedImage loadedImage = ImageIO.read(Game.class.getResource(path)); BufferedImage formattedImage = new BufferedImage(loadedImage.getWidth(), loadedImage.getHeight(), BufferedImage.TYPE_INT_RGB); formattedImage.getGraphics().drawImage(loadedImage, 0, 0, null); return formattedImage; } catch(IOException exception){ exception.printStackTrace(); …

Member Avatar
Member Avatar
+0 forum 1

.

Member Avatar
Member Avatar
+0 forum 1

I have developed a game for android mobiles ["Rise Up Air Balloon"](https://play.google.com/store/apps/details?id=com.abacus.riseup). I want to updatte it. Kindly suggest me something if it is better to update https://lh3.googleusercontent.com/rB-fPEBiaGzT_ubSzCtSfftC4pKkIm5buAS2_DhQz4_exYFCrjbcN2T1NhkmM0A3Jj0=s180-rw

Member Avatar
Member Avatar
+2 forum 3

Hello everyone, I am Bastian, i would be very grateful if anyone could help me on this one. I want to self-study about creating a Hotel Management program in Netbeans but i am afraid that i just have a basic knowledge in Java. I studied Programming but unfortunately i have to stop due to my financial issues. So i am thinking if anyone could give me some tips and tricks in order for me to create a program. I want to learn by my own but i have no idea where to start. Thank you very much.

Member Avatar
Member Avatar
+0 forum 1

hi there i have some python coding which i need to convert to java can ne1 help me please email me back if you can help then i will show you the coding much appriciated

Member Avatar
Member Avatar
+0 forum 9

It's not showing the image in the terminal window or the jframe. import java.awt.Canvas; import java.awt.Color; import java.awt.image.BufferStrategy; import java.awt.Graphics; import java.lang.Runnable; import java.lang.Thread; import javax.swing.JFrame; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.IOException; public class Game extends JFrame implements Runnable{ import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; public class RenderHandler{ private BufferedImage view; private Rectangle camera; private int[] pixels; public RenderHandler(int width, int height) { //Create a BufferedImage that will represent our view. view = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); camera = new Rectangle(0, 0, width, height); camera.x = -100; camera.y = -30; //Create an array for pixels pixels = ((DataBufferInt) view.getRaster().getDataBuffer()).getData(); } …

Member Avatar
Member Avatar
+0 forum 1

I made this game equivalent to tictactoe but with a slight twist called find the X between two players using socket programming with Java. Don't know where I went wrong in trying to find the X but for some odd reason my count variable never updates allowing the victory message to never pop up. Basically the game is as follows, the dealer starts by placing the X then the spotter has to guess where it is by placing the O. Still quite new to Java and socket programming, I followed a few Java socket programming examples which is what led …

Member Avatar
Member Avatar
+0 forum 5

Hello I'm writing a program that reads in data from a file to create an array of clients and stocks. I completed my client class and stock class. I'm stuck on my driver. ![Screen_Shot_2019-12-02_at_11_53_13_PM.png](/attachments/large/4/0ceae90458b69aa4d08f7e5937ba4a6e.png) This is what I have it prints the text file but where would I include the array its part of the project? I would love any feedback.

Member Avatar
Member Avatar
+0 forum 1

I am trying to get a program to work that asks for a user input to count by that number and display 10 numbers per line. I can not get it to display 10 numbers per line. If anyone can explain to me what I am doing wrong? public static void main(String[] args) { //final int START = 5; final int STOP = 500; int NUMBER_PER_LINE = 10; Scanner val = new Scanner(System.in); System.out.println("Enter your value "); int START =val.nextInt(); for(int i = START; i <= STOP; i +=START) { System.out.print(i + " "); if(i % NUMBER_PER_LINE == 0) System.out.println(); …

Member Avatar
Member Avatar
+0 forum 9

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
Member Avatar
+0 forum 1
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
Member Avatar
+2 forum 4

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
Member Avatar
+0 forum 1

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
Member Avatar
+0 forum 3

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
Member Avatar
+0 forum 1

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
Member Avatar
+0 forum 6

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 …

Member Avatar
+0 forum 0

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
Member Avatar
+0 forum 4

The End.