Design And Implement Application That Produces Multiplication Table

Feb 28, 2014

Design and implement an application that produces a multiplication table, showing the results of multiplying the integers 1 through 12 by themselves

View Replies


ADVERTISEMENT

Rows And Columns In The Form Of Multiplication Table?

Mar 12, 2014

I am making rows and columns in the form of a multiplication table, listed below is my code:

package assignments;
 public class MultTable {
public static void main (String [] args) {
  int row, column, x, y;
  for(row = 0; row < 8; row++)

[Code] .....

If you see my sample run you can see that I have the multiplication table down but, I haven't completed it. I have to make the bottom left half of the whole table blank somehow. For example, I have to make it halfway through the middle of the table the bottom left half full of white space...

5 6 7 8 9
12 14 16 18
21 24 27
32 36
90

hm, it's supposed to be the other way around horizontally.

View Replies View Related

Multiplication Table - Single Field To Store Integer

Feb 26, 2014

Steps are:

Create a new class, MultiplicationTable, that has a single field to store an integer multiplication table

Create a constructor that takes a parameter for the maximum number to be multiplied in the table. For example, MultiplicationTable(9) would have a maximum value of 81, where as MultiplicationTable(12) would have a maximum value of 144. Initialize the field in the constructor with the appropriate multiplication values.

Create a multiply method that takes two integers as parameters and returns their multiplication value by looking it up in the field. Make sure to test this method with values greater than the max the table should have stored. How can you handle these cases?

Create a main method that repeatedly tests multiply by printing out the entire multiplication table.

So far i got:

Java Code:

package collectionsHw_netid;
class MultiplicationTable {
// field
int mt;
MultiplicationTable(){
{
for (int i=0; i<=9; i++)

[Code] ....

Is my code right? also how do i print it out? the professor told us that everything should be outside of the main method...

View Replies View Related

Servlets :: Generate M By N Multiplication Table Based On User Input

May 8, 2014

I have a basic html form with one user input text box labeled "Enter a number" and a submit button labeled "Create a multiplication table". This is the working with a servlet to display an html formatted multiplication table. Everything else is working fine just the formatting is off; I can't seem to get the top row and far left column to number properly. It should look like this with the top row of numbers beginning with a blank cell and then numbering 1 thru n (depending on what the user selects. The first column should be the same, a blank cell and then 1 thru n. Then the multiplication table should be in the rows/columns of the table. Picture this:

I can't get mine to start with a blank cell in the top left-hand corner, instead it has 1 in that cell and the table starts calculating with 2x2.

Servlet code:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

[Code] ....

View Replies View Related

Design And Implement Word Guessing Game

Dec 29, 2013

I have a project about programing a game in java . In this project you are required to design and implement a word guessing game. In the game, user selects one of the available dictionaries (animals, plants, technical, names, etc. ), and the program randomly chooses one word from that dictionary and displays it by scrambling the letters. The user tries to guess the word while a guess counter starts to count down (lets assume it starts from 5).

While counter counts towards zero, the program chooses -randomly- two misplaced letters and puts them into correct positions to reveal the word more and give the user a hint. However, giving a new hint reduces the total value of the question. Lets say if the initial value of the question is 500 when all letters are scrambled, it reduces to 400 after 1st incorrect guess and hint, then after every incorrect guess it reduces more. You can determine the value of the question by the length of the word. The other details of the game is as follows:

1.You must design at least three classes (for example game, scrambledword, and dictionary).

2.Dictionaries are written in text files. If you design a class for dictionary, it must be constructed by a user chosen category ((animals, plants, technical, names, etc). In the constructor, the dictionary text file corresponding to this category must be opened and read; and words in that dictionary must be read into memory (e.g. String array). You must submit your dictionaries with your code. Do not share dictionaries between friends.

3.The game will record your total points and name in a text file where a hall of fame which has different users and their total points in 10 questions. You can design and implement a class for this.

4.Bonus+5%: Put user interface modules textboxes, buttons, etc Or

a.Use class hierarchy

b.Use of thread and timers and reducing the question value by timer instead of guesses.

View Replies View Related

Design And Implement GUI Front End For Computerized Version Of Battleship

Feb 21, 2014

Code for implementing a simple computerised version of Battleships has been supplied. Examine the code ensuring that you understand it. The game is played against the computer.

A number of ships (default is 6) are place randomly on a 4 x 4 grid. A ship occupies one square only. The player then guesses the position of a ship. If he/she guesses correctly the ship is HIT and sinks. If the guess is incorrect the player loses a life. The default number of lives is 7. If the location has been guessed already, no lives are lost.

When the game starts, a 4 x 4 grid should be displayed.

The user should be allowed to enter/select a cell location. If the selected cell contains a ship, the ship will be destroyed. If not the player loses a life. The cell should display an appropriate picture, icon or message informing the user of its current state.

The number of lives and number of ships remaining should be displayed.

When the game ends an appropriate message should be shown informing the player whether he/she has won or lost. The positions of the ships should also be shown.

The purpose of this assignment is that students demonstrate an understanding of the Java Swing library and that he/she can navigate and use the API effectively.

Your finished GUI should be both user-friendly and aesthetically pleasing.

Ideally, the user should have the option to play another game, to quit or give up mid-game. You may also wish to include other options such as different levels of difficulty, etc.

View Replies View Related

Design And Develop Program To Implement Lazy Buddy System Algorithm

Jul 19, 2014

I want to know the java code for lazy buddy system algorithm which can be run in eclipse or netbeans

View Replies View Related

Swing/AWT/SWT :: Generalized Table Maintenance Design

Mar 17, 2014

it may reflect some of those changes that happened after you created the iterator but there is no guarantee. I think the state changes that take place after you start iterating are never reflected. But these are implementation details. As such we know that iterating through a ConcurrentHashMap may not give us the most recent updates that happened to the Map ( the ones that happened after we created the iterator ). We would use it if we either don't care about missing some of the updates or if we know that such updates are not likely and we want maximum concurrency in that kind of a setting.

This isn't the case with the iterator returned by a LinkedHashMap or a synchronized view of a LinkedHashMap.There are some small but significant incorrect things I have said in my response. Here is a better response.It may reflect some of those structural changes that happened after you created the iterator but there is no guarantee. I think the state changes that take place after you start iterating are never reflected. But these are implementation details. (This is an just an untested observation. Not even an implementation detail. As such we know that iterating through a ConcurrentHashMap may not give us the most recent structural updates that happened to the Map ( the ones that happened after we created the iterator ). We would use it if we either don't care about missing some of the structural updates or if we know that such updates are not likely and we want maximum concurrency in that kind of a setting.

I've since been looking at the new TableView class made available via JavaFX from this Oracle tutorial here. It looks like I can do the following:

1) Create a POJO class that contains the columns as properties of the class. Each object of the class represents a row.
2) Create a TableView class that contains a list of the new POJO class from 1) above. Any insertion of additional POJO class from 1) represents a new row inserted into the TableView class and this gets reflected immediately and automagically on the JavaFX GUI.

This is all great! But how do I do the following:

1) Access a specific cell in the table via a row name and col name?
2) Return all cells in a column as an array, by specifying the col name?
3) Have more than one GUI data binded to this TableView?
4) Specify the POJO class dynamically at run time? If I want to create an interface (say a web service) that allows someone to add columns, remove columns, etc at run time and this needs to be reflected both internally in memory and externally on all the connected GUIs?

View Replies View Related

Servlets :: Simple Web Application Design With JSP

Apr 13, 2014

I am trying to design properly a simple 1to50 game (yes, the one that is so popular among mobile apps), but as a web application that allows two player games. I tried to document myself on the technologies I could use and came to the decision that some kind of Java would be suitable. I know that HTML, HTML5, CSS, JavaScript are client side languages with what I can basically design the client application that runs on a web browser. I installed Tomcat web server, configured Java Servlet API, done some research on Servlets and JSP, but I still cannot really imagine how all of this can work. Servlets form the Controller, JSP files the Model? How can I make them communicate, how can Servlets "tell" JSP files what to dynamically generate? Can JSP files communicate with JavaScript? Is JavaScript even necessary?

I thought that this question is not basically about a specific thing regarding JSP or Servlets, more about design and general concept, that is why I put this question under beginning Java.

View Replies View Related

Windows Application Design Methods?

Feb 16, 2015

I need to get Windows application made.   Is there a graphical, drag&drop  layout tool in which I can place 'controls' such as buttons, panels, toolbars onto a window then write the code to respond to them? It seems to be common place in other systems.

View Replies View Related

Swing/AWT/SWT :: Making GUI Application Design Extensible

May 5, 2015

I have to create a Swing application for which i haved a set of requirements as,

1. there will be two JPanels ,left and right, on the main JFrame , left frame would contain a JTextField and a submit JButton ,user can enter values 1,2,3 ,in the JTextField and presses the JButton

a. if user enters 1, a JTextField will be shown on right JPanel
b. if user enters 2, a JTextField and a JRadioButton will be shown on right JPanel
c. if user enters 3, a JTextField and a JComboBox will be shown on right JPanel

So I have done that but when my boss sees the code behind this application he told me to make it more extensible i.e. if there is going to be an additional requirement for values 4 or 5 or 6 and so on , then i have to make minimal changes in my code or no change in my code and it should work . how this can be done ? is it possible make such software design ?

public class DesktopApp extends JFrame {
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(DesktopApp.class);
private JPanel jp, jp2, mainPanel;
private JLabel jl, jl1, jl2, jl3, jl4, jl5;
private JTextField jText, jText2, jText3, jText4;

[Code] ....

What wrong am i doing here in this code which in not considered to be an extensible design ?

View Replies View Related

JSF :: How To Implement Finger Printing System In Web Application

May 9, 2014

I'm currently meddling with javaScript in order to implement a fingerPrinting system in my web application. I've developed the following example in which I can get all the necessarily data:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">

[Code] ....

Which works correctly.

So when I tried to run it in the following page:

<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>SET - Simulador Econômico Tendências</title>

[Code] .....

It simply won't work!

The function faz() is called and only the first "alert" popup is called, the second one which should show what is returned by dadosDaTela() isn't generated, why is that?

View Replies View Related

Servlets :: Implement (Keep Me Signed In) Option In Login Page Of Application

Jun 2, 2014

I want to implement a 'Keep me signed in' option in the login page of an application. I have noticed this option is present in the form of a checkbox on the login page of many websites but i don't know how it can be coded . When selected, a user is no longer asked for his username and password on subsequent sessions but he is automatically given access.

View Replies View Related

How Does Code Produces Correct Value

Mar 11, 2015

I have a simple WORKING Factorial program code but I don't understand how it works.Here is code snippet

public class Factorial{
public static void main(String[] args){
long limit = 5;
//long factorial = 1;
 
[code]....

My question is - every time in a given FOR loop if Factorial value (highlighted and bold above) is initialized / reset to "long factorial = 1" then how does code produces correct values? Because correct values can be produced only if interim factorial results are saved/stored and used next time to multiply with "factor" value.

Here instead of retaining it, we initialize or reset to 1 so every time you multiply by 1 and it should produce 1! = 1, 2! = 2, 3! = 3, 4! = 4 etc which would be an incorrect result.

View Replies View Related

Create Array That Produces Triangular Number Sequence?

Nov 12, 2014

My code complies but it won't run and I'm not sure why. ArrayIndexOutOfBoundsException.

I'm trying to create an array that produces the Triangular number sequence:1, 3, 6, 10, 15, 21, 28, 36, 45, ...

Attached image(s)

View Replies View Related

Applets :: Subtraction And Multiplication With One Click?

Mar 21, 2014

This is what I ended up with and it is not what I want.

How do I convert this to an applet that would run independently on a desk top out of all these shells?

[URL]

View Replies View Related

Making Squares Of Numbers Without Multiplication?

Oct 22, 2014

so for my computer science class, we have the following problem:

In your documentation be sure to say which loop you thought was easier to implement for this program and why Write a program that produces the following outputs. The first line of output must be written using a For-Loop. The second, using a While-Loop and the third using a Do-Loop.

You look at the program and smile because you see that the series is just the numbers 1-10 squared...just one line is in reverse order. No problem! As you start typing you discover that the number 8 key on your keyboard is not working. For this program you are unable to use the multiplication key

So, back to the drawing board. By staring at the sequence a light comes on and you are able to quickly finish this program WITHOUT using mulitiplication (or the Math class/ solve with arithmetic operators +, - or / ) .

Sample output:

For Loop
1 4 9 16 25 36 49 64 81 100

While Loop
100 81 64 49 36 25 16 9 4 1

Do While Loop
1 4 9 16 25 36 49 64 81 100

I have the "for" done, but I did it with a "for" in the beginning but then had a multitude of nested "if" loops so that I could do 7*7=7+7+7+7+7+7+7

View Replies View Related

Java Calculator - Multiplication And Division

Apr 24, 2015

I am having problems with my code I have added the multiplication and division but they will not display also how can I correct any error when dividing by zero?

import java.awt.*;
import java.awt.event.*;
public class calculator2 extends java.applet.Applet implements ActionListener {
TextField txtTotal = new TextField("");
Button button[] = new Button[10];

[Code] .....

View Replies View Related

Sparse Matrix Addition And Multiplication

Nov 4, 2014

Code for sparse matrix addition and Multiplication...

View Replies View Related

Java - Integer Limits / Multiplication And Exponents?

Jan 10, 2014

noticed that if I use integers only and simple multiiplication to get my exponent results (in this instance I was looking into Base 26) what is returned is odd, BUT consistent results once I surpass the integer upper limit of 2,147,483,647. I anticipated that once this limit was reached the program would blow up somehow, but no.

public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter an integer exponent: ");
int i = Integer.parseInt(br.readLine());
CountAlpha ca = new CountAlpha();

[code]....

View Replies View Related

Multiplication Worked But Division Didn't Work

Mar 5, 2014

I was trying to execute the following program and the multiplication worked but the division didn't work.

import java.util.Scanner;
public class BodyMassIndex {
public static void main(String[] args) {
// Prompt the user for weight and height
// Create a scanner
Scanner input = new Scanner (System.in);
System.out.println("Please enter your weight in pounds");
int weight = input.nextInt();
System.out.println("Please enter your height in inches");
int height = input.nextInt ();
double BMI = weight * (0.45359237)/ (height * 0.0254)*(height * 0.0254);
// the weight * (0.45359237) executed but it wasn't divided by (height * 0.0254)*(height * 0.0254)
System.out.println ("Your BMI is "+BMI);

View Replies View Related

Prompt User For Input Number And Check If It Is Greater Than Zero - Java Multiplication

Apr 13, 2014

Write a program that prompts the user for an input number and checks to see if that input number is greater than zero. If the input number is greater than 0, the program does a multiplication of all the numbers up to the input number starting with the input number. For example if the user inputs the number 9, then the program displays the following sum:

9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362880

That's the question I'm getting and so far all I've got is

import java.util.Scanner;
public class Lab4Q3
{
public static void main (String[] args)
{
int keyboard;

[Code] .....

View Replies View Related

JavaFX 2.0 :: How To Define Cell In The Table By Table Event

Mar 23, 2015

How to define Cell in the table by table event?
 
I need to process one component drag to the table. I misunderstand, how I can see to which Cell fall the component. I tried to use Event and Mouse event handlers in my custom Cell, but they do not work. I can copy the drag event to the table and table handles it, but how to get needed Cell I cant understand.

View Replies View Related

Adding Data In Table But The Table Is In Another Frame

Mar 13, 2014

This is my codes in a button that if I click it . that information will send to Jtable but the problem is the jtable is in another frame so how can i connect this ?

DefaultTableModel model = (DefaultTableModel)
new admin().tableBagtags.getModel();
if (txtName.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Please fill out all fields.", "Error!", JOptionPane.ERROR_MESSAGE);

[Code] .....

View Replies View Related

JSF :: Unable To Add Mysql Table Columns To Table

Apr 29, 2014

I'm trying to add some mysql table columns to JSF table. And I'm getting error:

/index.xhtml: The class 'logon.User' does not have the property 'description'.

User.java
package logon;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

[Code]...

View Replies View Related

EJB / EE :: Convert Standalone Java Thread Application Into Web Application In Tomcat

Nov 17, 2014

convert or move standalone java thread application into Tomcat server container for accessing its JNDI services? Also is it possible to schedule this thread application in Tomcat server? is it possible to keep this app in tomcat as web application and schedule in window's scheduler.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved