Number Of Paths Coordinate System

Oct 18, 2014

I've been pondering about this algorithm for about a week but I'm still not able to write a "fast" working method/algorithm to solve the Number-of-paths-exercise we were given in my class />

So here's the task:
Write an efficient java program "Paths" which solves the following task:

- Read input n ∈ N and give output a(n) which is the number of paths from (0,0) to (n,0)
it is not allowed to go over the diagonal (m,m) and also not below the x-axis (m,0)

Here are the allowed steps:
u = (1,1), U = (1,4), d = (1,−1), D = (1,−4) and H = (1,0)
steps are performed in a two-dimensional-coordinate-system!

View Replies


ADVERTISEMENT

Program Deals With Variation Of Geographic Coordinate System

Aug 22, 2014

This program deals with a variation of the geographic coordinate system with Greenwich at 51° 28' 38" N. The program will be adding the three values of one coordinate to the three values of the second coordinate. Though the maximum value for seconds and minutes is 59, the user can enter values greater than that number when prompted. The maximum degree is 360 for this assignment though the user can enter values greater than that number.

View Replies View Related

Finding Number Of Paths Between Two Nodes

May 5, 2015

Is it possible to find the number of paths between two nodes in a directed graph using an adjacency matrix? I know how to find all said paths of a given length by using matrix exponentiation, but I don't know how to find all the paths. The professor didn't note it in the assignment but I assume she meant all simple paths because this is a cyclic graph, so there's a potentially infinite number of paths.

I'm thinking I should use matrix exponentiation to find the number of paths of lengths 1 to n-1, where n is the number of nodes in the graph. Then add the number of paths for each length together. Would this work?

View Replies View Related

Number System Converter

Feb 15, 2013

This program requires knowledge of manipulation of Java String objects and methods. It also requires knowledge of Number System Conversions.

// Lab16MATH05st.java
// The Number System Converter
// This is the student, starting version of the Lab16MATH05 assignment.

import java.util.Scanner;
public class Lab16MATH05st
{
public static void main (String args[])
{
System.out.println("Lab16MATH05 - Number Conversion Program

[code]....

90-Point Version Specifics: The 90-point version requires that you write both the fromHexToBin and fromBinToDec methods.

90-Point Version Output

95-Point Version Specifics {The 95-point version requires everything from the 90-point version and adds the fromBinToHex method. For this version, you may assume that the binary number will have a multiple of 4 bits.

95-Point Version Output

100-Point Version Specifics: The 100-point version requires the same methods as the 95-point version; however, the fromBinToHex method needs to be improved so it can convert regardless of the number of bits.

100-Point Version Output

105-Point Version Specifics: The 105-point version requires everything from the 100-point version and adds the fromDecToAny method. For this version, the method needs to be able to convert from decimal to any base between 2 and 10. Base 16 is not required for this version.

105-Point Version Output

110-Point Version Specifics: The 110-point version requires the same methods as the 105-point version; however, the fromDecToAny method needs to be improved so it can also convert to base-16.

View Replies View Related

How To Make The Program Understand 10 Number System

Oct 24, 2014

I want to create a program where i can output a number. ex. 3452 And the program will output 3000: three thousand 5: five 53: fifty-three

How can i make the program understand the 10-number system?

View Replies View Related

Averaging Grades Program - System Crashes On Negative Number Input

Sep 30, 2014

I do now have the problem where i have to insert the numbers 1 to 100 individually in order to allow the program to accept a grade as high as 100%.

Also as soon as i type in a negative number the system crashes and shows me a error as attached.

/*
Averaging grades
To use the Java Swing interface to calculate the average of up to 50 grades.Average is calculated once -1 is entered as a value. The grades are then sorted from lowest to highest and displayed in a content pane which also displays the average.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing .*;
import javax.swing.text.*;
public class Averages extends JFrame {
//construct components
JLabel sortPrompt = new JLabel("Sort By:");

[Code] ....

View Replies View Related

How To Use Coordinate In Second Code

Apr 16, 2014

how I can use this class:

Java Code:

public class Coordinate{
public int x;
public int y;
publ Coordinate(int x, int y){
this.x = x;
this.y = y;

[code]....

How would I use Coordinate in the second code?

View Replies View Related

All Permutations Of 2 Coordinate Int Array

Apr 12, 2014

I have a set of 2D arrays, structured as so: int[][] cage = new int[someLength][4]. Each array has a set column length of 4; the first two columns are all that concern us with this problem. They are used to define the row and height respectively of a point (e.g. 2,4).

What I need is to generate all possible permutations of the points using both row and column coordinates from the 2D array. I found a working method to generate all permutations for 1D array of ints here: [URL] ..... , under update 2 of the first answer.

Here is an example of a possible input and corresponding output desired:

In: (1,0)
(1,1)
 
Out:(1,0),(1,1)
(1,1),(1,0)

Ideally the result will be stored in a 2D array of ints.

View Replies View Related

All Permutations Of 2 Coordinate Int Array?

Apr 12, 2014

I have a set of 2D arrays, structured as so: int[][] cage = new int[someLength][4]. Each array has a set column length of 4; the first two columns are all that concern us with this problem. They are used to define the row and height respectively of a point (e.g. 2,4).

What I need is to generate all possible permutations of the points using both row and column coordinates from the 2D array. I found a working method to generate all permutations for 1D array of ints here: My link, under update 2 of the first answer.

Here is an example of a possible input and corresponding output desired:

In: (1,0)
(1,1)
Out:(1,0),(1,1)
(1,1),(1,0)

the result will be stored in a 2D array of ints.

View Replies View Related

Coordinate Conversion Project - Rectangular To Polar

Mar 6, 2014

Ok Im trying to create a code right now that will take a table of rectangular coordinates and convert them to Polar coordinates in the constructor. I will eventually calculate the total distance between all points in the calculateDistancePolar method but for now I am using it to test.

It doesnt like line 29 and 31 of the class Polar and I cannot figure out why.

public class Test {
public static void main(String[] args) {
double[][] coords = {{86.92, 2.47},{70.93, 27.81},{97.74, 34.36},{30.90, 35.14},{51.66, 31.70},{0.830, 21.77},{55.91, 66.62},{32.92, 75.23},{65.26, 72.53},{83.90, 4.710}};
System.out.println("X,Y Coordinates are:");
outputArray(coords);
Polar myTest = new Polar(coords);

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Why Negative Offset Of Y Coordinate Required In Program

Feb 3, 2015

import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
/**
An applet that shows a rotating globe.

[Code] ....

View Replies View Related

Coordinates Are Inside Of A Right Triangle On Imaginary Coordinate Plane

May 24, 2014

I'm having a random x and y coordinate generate and I need to check if the coordinates are inside of a right triangle on this imaginary coordinate plane.

View Replies View Related

Displaying All Paths In A Tree

Nov 20, 2014

I know what the tree data structure is, how it works, etc., but I need to design a method that will sequentially print out all the paths in the tree (i.e. for each node).

The method as provided is

private static String getAllPaths(final BinaryNodeInterface<Character> root) { }

Now the string that must be returned needs to be of the format:

root.getData() + " " + path + "
"
root.getData()[1] + " " + path[1] + "
"
etc.

The pseudocode I was thinking of doing was something along the lines of:

paths
if(root.getData() = null) return paths;
path = ?; // absolutely no clue what to do here
paths += root.getData() + " " + path + "
";
if(root.hasLeftChild()) {
newPath += "0";
paths += begin recursion;
}
if(root.hasRightChild()) {
newPath += "1";
paths += begin recursion;
}
return paths;

Problems:

(1) I don't know how to determine "path" before the left and right children check (the root node's path is "", the first left node's path is "0", the first right node's path is "1", pattern continues with left being "0" and right being "1").
(2) I don't know where to put newlines precisely.
(3) I'm not sure how to get the print layout precisely as it is supposed to be. At most I've been able to just get the last number in the sequence (i.e. if it was supposed to be "1000", I could get "0".

I am working with the pseudocode formulation, especially in regards to the logic and formatting. I think once I have an understanding of what is going on, I can solve it. And yes, I've gone through a couple pseudocode rewrites (a few hours worth) and haven't gotten anywhere which is slightly unnerving.

View Replies View Related

Can't Get Relative Paths To Work

Apr 25, 2014

I can't get Relative paths to work. I have created the class.dat file and I can't get java to recognize it. I am using Eclipse as an IDE. Was wondering if I could get Eclipse to recognize it. I tried with a .txt file as well and couldn't get that to work.

import java.io.*;
public class ReadBytes
{
public static void main(String[] args)
{
try
{
FileInputStream file = new FileInputStream("class.dat");

[Code] .....

View Replies View Related

How To Print All Paths Of Cyclic Graph

Sep 14, 2014

I print a path like below with iteration. It is redundant as you see. How can I remove the redundant path? im using arrayList .

1. [0, 1]
2. [0, 1, 2]
3. [0, 1, 3]
4. [0, 1, 3, 4]

View Replies View Related

File Paths In Eclipse / Jgrasp

May 1, 2014

So I downloaded jgrasp and eclipse on a new computer and am trying to figure out how their filing/path system works.In eclipse I created a new project under which I've imported all my files for my comp sci class, so they're all under this one project which is my only project. I attached a pic of what my eclipse workspace looks like. In this project folder is a file I'm trying to run.

I keep getting an error saying "editor" does not contain a main type.When I change my class name to the project folder I end up getting an option to run the program as an applet or an application, but either one I choose I get the same error message. In the bottom it gives me a warning saying

DescriptionResourcePathLocationType
Build path specifies execution environment CDC-1.1/Foundation-1.1. There are no JREs installed in the workspace that are strictly compatible with this environment. CS1050AssignmentsBuild pathJRE System Library Problem

I tried running the program in jgrasp and got this error

----jGRASP wedge2 error: command "javac" not found.
---- This command must be in the current working directory or
---- on the current system PATH or jGRASP PATH to use this function.
---- System + jGRASP PATH is "C:UsersQudrat.MommandiDocuments;C:Windowssystem32;C:Program Files (x86)InteliCLS Client;C:Progra

[code]...

I have the JDK installed in program files, I have the correct versions of eclipse and Jgrasp, and have uninstalled / reinstalled the JDK/Jgrasp/Eclipse so I don't know what the problem is?

View Replies View Related

Drawing Interactive Paths In JavaFx 8?

Aug 6, 2014

I am trying to make a GUI that allows the user to input the NumberLink puzzle (through mouse action events), and then, displays the puzzle in a grid with features to draw a path, and undo it. This is almost exactly the same functionality as in Numberlink on Nikoli

1. In my project, I have a Stage in which a setup scene prompts user for rows and columns (to take size of puzzle),

2. Then, it generates an empty grid (I'm thinking of using a GridPane here), and the user clicks the squares to enter the numbers into the square. this phase isnt a problem if I use text fields and mouse listeners and store info in a grid... the next phase is what I'm stuck at... unless I know exactly how to do that, I cant make progress...

3. In the third stage, I have to display the numbers to the user just like on the Nikoli site (the highlighting number pairs on mouse hover is a necessary feature too, which I think I can handle with CSS).. and the user should draw paths between the numbers, just as on that site ( I thought VLineTo and HLineTo classes would be suitable.. but I'm not sure, and cant find any alternatives) .....

So with this in mind, I made FXML based dummy gui layouts to test if my ideas work... And I cant get the GridPane to have lines drawing atop it (meaning, I cant place Line objects like HLine on top of the grid panes).... is there any other way to do what I need to do ? I also thought of making canvases in a grid (each square is its own canvas)

How I can implement a user inputted path drawing ??

View Replies View Related

List All Possible Paths From Point A To B Using Recursion?

Apr 12, 2014

From a two-dimensional grid 5x5 that looks like this:

(0,0)(0,1)(0,2)(0,3)(0,4)
(1,0)(1,1)(1,2)(1,3)(1,4)
(2,0)(2,1)(2,2)(2,3)(2,4)
(3,0)(3,1)(3,2)(3,3)(3,4)
(4,0)(4,1)(4,2)(4,3)(4,4)

We have Starting point that is (3,0) and an ending point is (1,3). We can only move up and right to get to the ending point by using recursion. We have to list all possible paths from (3,0) to (1,3)

Example: paths:(3,0)(2,0)(1,0)(1,1)(1,2)(1,3)
(3,0)(2,0)(2,1)(1,1)(1,2)(1,3)
etc...

I was able to get from (3,0) to (1,3) but how to list the other paths. This is my code so far

public class Program7 {
public static void main(String[] args){

int size = 5;

int x1 = 3;
int y1 = 0;
int x2 = 1;
int y2 = 3;

System.out.println(x1+" "+y1);
System.out.println(x2+" "+y2);

int [][] path = new int[size][size];
grid(path,x1,y1,x2,y2);

[code].....

View Replies View Related

How To List All Possible Paths From Point A To B By Using Recursion

Apr 12, 2014

From a two-dimensional grid 5x5 that looks like this:

(0,0)(0,1)(0,2)(0,3)(0,4)
(1,0)(1,1)(1,2)(1,3)(1,4)
(2,0)(2,1)(2,2)(2,3)(2,4)
(3,0)(3,1)(3,2)(3,3)(3,4)
(4,0)(4,1)(4,2)(4,3)(4,4)

We have Starting point that is (3,0) and an ending point is (1,3). We can only move up and right to get to the ending point by using recursion. We have to list all possible paths from (3,0) to (1,3)

Example: paths:(3,0)(2,0)(1,0)(1,1)(1,2)(1,3)
(3,0)(2,0)(2,1)(1,1)(1,2)(1,3)
etc...

I was able to get from (3,0) to (1,3) but how to list the other paths. This is my code so far

public class Program7 {
public static void main(String[] args){
int size = 5;
int x1 = 3;
int y1 = 0;
int x2 = 1;
int y2 = 3;
System.out.println(x1+" "+y1);
System.out.println(x2+" "+y2);

[Code] ....

View Replies View Related

Method Get In Type Paths Is Not Applicable For Argument

Jun 4, 2014

I am using Oracle Java 8 in Eclipse working on both Ubuntu and OSX. I have this code:

Java Code:

private static String getConfigDir(){
Path configDir = Paths.get(homeDir(), homeConfig(), appName());
return configDir.toString();

[code]...

But for the method get() of Paths, I get this error in eclipse.The method get(String, String[]) in the type Paths is not applicable for the argument..Yet on the Oracle documentation site, it uses a similar example:

Path p5 = Paths.get(System.getProperty("user.home"),"logs", "foo.log");

View Replies View Related

Managing Class Paths On Different Operating Systems

Jun 5, 2014

I use git as my SCM and I use both Ubuntu and Mac OSX. The home directory of the two operating systems are different and there lies the problem. When I commit the .classpath to version control, it looks something like this:

Java Code:

<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/Users/MyUser/Documents/github/Gateway/GDGateway/java-json.jar"/>
<classpathentry kind="lib" path="/Users/MyUser/Documents/github/Gateway/GDGateway/postgresql-9.3-1101.jdbc41.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath> mh_sh_highlight_all('java');

Now when I update my project on Ubuntu. I have to change the build path again because it is referencing paths on OSX. And this goes back and forth. Rather than remove this file from git with .gitignore, I'd prefer to use a global environment variable like as follows:

Java Code:

<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="$HOME/Documents/github/Gateway/GDGateway/java-json.jar"/>
<classpathentry kind="lib" path="$HOME/Documents/github/Gateway/GDGateway/postgresql-9.3-1101.jdbc41.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath> mh_sh_highlight_all('java');

Is this possible?

View Replies View Related

Create Compound Shapes / Paths In JavaFX?

Apr 28, 2015

Is there some way to create compound shapes/paths in JavaFX?

For the record I'm not implying the use of the methods intersect, subtract, or union. These produce other shapes. A compound shape/path is one that has a knockout of some sort. For instance, a circle within a circle, such as in a 2d donut shape. Alternatives do not include a circle with a thick stroke nor an overlayed circle with the background color. Specifically, JavaFX supports the FillRule, in the case of the Path object. However, there doesn't appear to be an "add" method as there was in the Area shape in Swing.

View Replies View Related

Java Servlet :: Storing Images In Folder And Their Relative Paths In MySQL Database

Nov 16, 2012

I am developing an web application with servlets and jsp. I have an issue to store images. I am storing images in folder and their relative path's in mysql database.

When I retrieve path from database then using <IMG> tag i have displayed image like:

     out.println("<td><img src="+user.getPlaceImage()+" width='70' height='50' /></td>");

It is working fine with internet explorer but not working (that is Not displaying image) in chrome/mozilla.

How to display that image in all browsers....

View Replies View Related

Number Guessing Program - Computer Guesses A Number That User Is Thinking Of Within Certain Range

Mar 28, 2015

I have a beginning Java Program I have been working on that creates a number guessing program where the computer guesses a number that the user is thinking of within a certain range. I so far have the program below, but need getting rid of a few kinks/ adding features.

-First, I need to set it up so that the user will be prompted and give a range. It should run and produce something like this:

Welcome to this first-ever mind-guessing program!

Please pick a range (higher than 1 and no larger than 50): 32

You will choose a number between 1 and 32... and I will try to guess it.

With each of my guess, you will tell me whether I am too high (h or H), too low (l or L), match (m or M), or you want to quit (q or Q). My objective is to find the number using as few guesses as possible.

-Second, the game is supposed to give up and restart after failing the five, guesses, but for some reason, after it fails the fifth time, it prompts a fifth guess once again instead, then restarts after- I need to prevent this, so that it should look something like this:

My fourth guess is 17: h
My guess is too high?

My fifth guess is 16: h
*** I am unlucky this round. I give up.

Let's play!

My first guess is 10:
etc..

import java.util.*;
import java.lang.Math;
public class numguessprac1 {
// Declaring variables
public static String input;
public static int quit;
public static int guess;
public static int wins;

[Code] ....

View Replies View Related

User Enter 5 Digit Number And In Return List Each Number On Their Respective Lines

Sep 16, 2014

So I am currently writing my first assignment and have run into problems with my coding. The task was to have someone enter a 5 digit number and in return, I list each number on their respective lines. We also must create an error if a number other than 5 digits was entered. My problem is that when they enter a 1 or 2,3,4,6,7,8 digit number.. the error message occurs along with the rest of the messages (listing the numbers, etc). I want the program to end (or even re-ask to enter the numbers) if they incorrectly enter the data.

View Replies View Related

Program That Takes A User Inputted Number And Converts It To A Binary Number

May 5, 2014

trying to write a program that takes a user inputted number and converts it to a binary number.

Here's what I have:

package com.java2novice.algos;
import java.util.Scanner;
public class Converter {
static Scanner console = new Scanner(System.in);
public void printBinaryFormat(int number){
int binary = console.nextInt();

[Code]...

Bugs on:

Line 13
Line 17
Line 23

View Replies View Related







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