PageRank In Naive Manner With Graph Nodes As Pages And Subsequent Calculations

Apr 15, 2014

Trying to implement PageRank in a naive manner with graph nodes as pages and subsequent calculations. Correcting the code.

import java.util.*;
import java.io.*;
class PageRank {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter no.of pages");
int n=sc.nextInt();

[Code] .....

View Replies


ADVERTISEMENT

How To Get Shortest Path Between Two Nodes In Adjacency Matrix Using Undirected Weighted Graph

Apr 26, 2014

how to get shortest path between two nodes in adjacency matrix using with undirected weighted graph using BFS algoritham java program??

View Replies View Related

JComboBox Should Be Used In A Generic Manner

Sep 9, 2014

I recently posted that JComboBox should be used in a generic manner. I presumed that once declared, with some type Foo, that one could then do:

Java Code:

JComboxBox<Foo> cb = new JComboBox<>();
// sometime later
Foo foo = cb.getSelectedItem(); mh_sh_highlight_all('java');

However, getSelectedItem() is documented to return a type of Object so a cast is still needed. I can't understand (even for backward compatibility) why it doesn't return a type of the specified type. Many other old classes have been converted to generics so why should this be any different? I just found that one could use getPrototypeDisplayValue() but that seems counter intuitive.

View Replies View Related

Remember File Structure On Subsequent Openings?

Mar 12, 2014

I have a program I am working on, and have been using the following code:

Java Code:

private void checkQInstall(){
try {
qs = new File("C:MEMORYGAMEq.bin");
in = new BufferedReader(new FileReader(qs));
} catch (FileNotFoundException e) {
System.out.println("CALLED");

[Code] .....

Now my main issue is I am working on a project that could be used on a variety of systems. I understand that Java is designed for flexibility among OS's and that the way I have coded is designed for a Windows system (afaik). How to retain an installation directory so that on subsequent openings, the program knows where to open the file, without it being platform dependent.

View Replies View Related

Building Linked List Whose Nodes Data Is The Sum Of Nodes Of Other List

May 1, 2014

public void add(int d){
listNode l = new listNode (d, null);
l.next = first;
first= l;

public list Sum2List (list l1, list l2){
//variables
int sum;

[Code] .....

But I have a problem in my first listNode where it ll be pointing to null, thus in the sum2List method the program checks the while condition into false and doesn't go through the loop.

View Replies View Related

JSF :: Extension Of Pages In URL?

Jan 22, 2014

I am working in JSF and I've forgot few of the basics :'I use eclipse IDE to develope JSF projects. When I used to create a JSF file, it's extension is basically .jsp and when I ran that file in server .jsf extension used to be displayed in url. But recently, when I did the same thing I got .jsp extension in browser. in web.xml

when url-pattern is the following, .jsp extension is shown, eg: FileName.jsp

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

but when I change the url-pattern as per following, .jsf extention is shown , eg: FileName.jsf

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

even if I change the url-pattern to abc or xyz, the webpage url is shown in that format. eg: FileName.abc this is the actual scenario to specify extension of a jsf page, or is this an error.

View Replies View Related

Generate API HTML Pages?

Feb 28, 2014

I have a large product with many maven projects, all of which can be hierarchically tracked back to the same parent. The projects have javadocs and whatnot.

Icommand line instructions (Windows 7) to generate the full API documents html on my local machine (of all the projects together). If there is a maven command for doing this from the CMD, more the better.

View Replies View Related

Calculations Within A Set Method

Feb 13, 2015

I am almost done with the assignment, but I am having an issue with this step: "Create a field to hold the gallery commission. This field cannot be set from outside the class. it is computed as 20% of the price, and should be set whenever the price is set. Put the code to calculate and set the commission in the setPrice() method"

import java.util.Scanner;
public class PaintingHarness
{
public static void main(String[] args)
{
// put code here
// Created object so we can take input from the Scanner
Scanner input = new Scanner(System.in);
Painting myPainting = new Painting();

[code]....

View Replies View Related

JSP :: How To Get Total Number Of Pages In JavaScript

Apr 22, 2014

How to find the total number of pages in java script .how to achieve it.

View Replies View Related

JSF :: Passing Argument Parameters Between Pages

Jul 19, 2014

So I have an application where the user logs in (using j_security_check). User is taken to a welcome page where user's name is displayed as a link. When clicking that link I would like to take the user to a page where the user is able to update the credentials (password, address, etc). In this way the user only has access to the link related to that specific user's credentials. I am trying the following structure:

The welcome page (adminindex.xhtml) is:

<h:form>
Welcome to admin <h:commandLink value="#{userb.loggedUser}" action="#{userb.selectedUser}"/>
<f:param name="userName" value="#{userb.userName}"/>
</h:form>

The user backing bean:

public String selectedUser() {
userName = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(userName);
selUser=uServ.findByName(userName);
return "UpdateUser";

[Code] ....

The last line of the stack suggests that a null PK value is being picked up by the FacesContext method in the backing bean. I'm confused because the userName string IS the primary key of the user table which is structured like this:

CREATE TABLE sha_users
( username VARCHAR(255) NOT NULL
, password VARCHAR(255) NULL
, PRIMARY KEY ( username ) );

I'm sure I'm getting the concept of how to pass query parameters...

View Replies View Related

How To Count Number Of Pages Printed

Jul 20, 2010

i want to create a program in java which counts the number of prints taken from a printer..

View Replies View Related

JSF :: How To Render More Than One JSP Pages Into 1 Single View

May 15, 2014

I have an application where the WebContent folder has a number of .jsp pages like navigation.jsp, primarytabs.jsp etc.

The navigation.jsp contains a vertical menu and the primarytabs.jsp contains a tab on top, and some other jsps contain individual components.

When I run the application of the application server, it opens up a welcome page, and all these navigation items, and tabs and others merge into a single view and show us a well formed combination of all these components.

I did some studying and read about "composite views". But I wasn't sure if I can call this composite view or not.

How JSF combines all these jsps into one view and where to find that "binding" within the code so I can make the relevant changes?

View Replies View Related

Accessing Data For Calculations?

Feb 18, 2015

I've created a method to calculate the ratio of one vowel to another, but I was hoping to get some feedback on another way I could approach the problem. The first bit of code is to find the vowels and assign them to an array ( for me, it seemed the easier thing to do in order to easily access the data). In the other bit of code, I have a method with two arguments (the vowels) to calculate the ratio.

public void findVowels(StringBuilder message, String delimiter) {
subString = message.toString().toLowerCase().split(delimiter);
vowelCounter = new int[5][subString.length];
// Remove all whitespace
for (int index = 0; index < subString.length; index++) {
subString[index] = subString[index].replaceAll("s", "");

[code]....

View Replies View Related

Complex Number Calculations

Jan 25, 2014

A complex number is defined as z=a+i*b, where a is the real part, and b is the imaginary part. In other words, in order to define a complex number, we need the two floating numbers a and b. Write methods that perform for each of the following operations with complex numbers z1 = a1 + i*b1, and z2 = a2 + i*b2:

Addition: z1 + z2=(a1+a2) + i*(b1+b2)
Subtraction: z1 - z2=(a1-a2) + i*(b1-b2)
Multiplication: z1*z2 = (a1*a2 - b1*b2) + i*(a1*b2 + b1*a2)
Division: z1/z2 = (a1*a2 +b1*b2)/(a2^2 + b2^2) + i*(b1*a2 - a1*b2)/(a2^2 + b2^2)

Create a test program that asks for the real and imaginary parts of two complex numbers from the user, and displays the results of the four operations, writing the formula as shown above, and replacing the a1, a2, b1 and b2 with the numbers entered by the user.The professor used the incorrect complex number equations and has notified the students of his error. I have run into a few problems thus far.

1. I'm not sure how to use floating numbers with the Math.pow(double, double) function, since its requires doubles!? So instead of using floating numbers, I've knowingly switched them all to double in order to see if the code itself is working properly for the purposes of this forum. Is there a way that I can modify this function so that it will work for floating numbers?

2. Regarding the division method, an error stating that c and d have not been initialized and I'm not sure how to change it because the other calculation methods work fine. Why do I need to initialize c and d in the division method and not the others?

3. Am I on the right path? I have surfed the web to see how others completed the program and they all appear very different than mine...

package program5;
import java.util.Scanner;
public class Program5 {
  static double a, b, c, d;
static double i = Math.pow(-1,1/2);
 
[code]...

View Replies View Related

Calculations On Text Box Inputs

Mar 7, 2014

I have made a simple form, it consists of 3 text box's textbox1, textbox2 and textbox3 as well as 1 button button1. What I want to be able to do is put numbers into textbox 1 and 2 and then show the multiplication of these numbers in textbox 3 when the button is pressed and I was wondering what is the standard way of reading these numbers from the text box and allowing us to do the conversion obviously in the textbox its a string and we need to convert to an int or double or whatever to be able to perform calculations on them then convert it back into a string to display in text box 3?

View Replies View Related

Program Returns 0 For All Calculations

May 28, 2014

this program works but returns zero for all the calculations. I checked everything there is no error but I dont know why is returning 0.

package mshproject3;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
public class HayloFactoryController {
public static void main(String[] args) {
String firstName = "";
String lastName = "";
String phoneNumber = "";
int aNbrOfVehicles = 0;
int aNbrOfFuelTanks = 0;
HayloFactory factory;

[code]....

View Replies View Related

Servlets :: How To Check For A Session As The User Goes Through Different Pages

Mar 18, 2014

I have a question about how to check for a session as the user goes through different pages. I am using Java beans and EL to pass data from page to page but I cannot figure out how to check for a session on the pages without the use of a scriptlet with an if else statement in it.

I do not want the user to be able to access any pages unless they are logged in. With a scriptlet, I can create a statement that says if session exists show name else redirect to login page.

From what I have read and what some of the wonderful members here have told me, scriptlets are a big no no these days. So, how do I do these without the use of a scriptlet?

View Replies View Related

Regular Expression In Java For HTML Pages

Feb 18, 2014

I need to parse an html web page to extract specific information from the tags in Java. For example,

<b>Species </b> Strain </td>

I need to look for the Strain info (Strain is variable in length) in the page. The whole web page is stored as a huge string. I need a regular expression that can identify all the Species and retrieve their corresponding strain info. how to do this or can propose some clever string manipulation methods in Java.

View Replies View Related

Support Smaller Number Of Frames Than Pages

Oct 20, 2014

I am working on this experiment code, I keep getting an exception:

run:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -256
at .MemoryManager.read(MemoryManager.java:68)
at .MemoryProcess.callMemory(MemoryProcess.java:39)
at .main(Lab3.java:29)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

The offending line is data=RAM[physicalAddress]; inside MemoryManager.java.

why this is exactly happening and thus correct my piece of code.

The code:

main.java
package experiment;
public class Main{
/**
* @param args the command line arguments

[Code].....

View Replies View Related

JSP :: User Server Side Validation In Pages

Apr 3, 2015

I have a Registration Form in which I am registering user to perform some sort like Entering messages I want to perform some Server Side validation.

Like suppose a user has Enter an Id then as soon as he start entering the Id then I want that this Id should be checked in database that if this Id exists in database or not.

and similar types of validation I want to apply on other fields to.

How can I acheive this?

View Replies View Related

Use Various Freemarker Templates To Create Web Pages For Website

Feb 23, 2014

I have a Java application and it uses various Freemarker templates to created Web pages for a Web site. Here is a snippet of one of my Freemarker templates that will display the fee description, fee charge, and an add button. The fee has to do with charges that pertain to automobiles. When I click on the "Add" button, I will be taken to another Web page. How would I send the fee.description and the fee.charge to the other page when I click on the "Add" button?

<tr class="${rowclass}">
<td class="leftalign">${Fee.description}</td>
<td class="centeralign"><#if Fee.charge??><#if Fee.charge?trim?upper_case != "No Charge"?trim?upper_case && lot.workOrderFee.charge?trim?upper_case != "Market Price"?trim?upper_case >$</#if>${Fee.charge}</#if></td>
<td class="rightalign">
<input type="button" name="buttonsub" id="buttonsub" onclick="javascript:window.location='myPage.html'" value="Add"/>
</td>
</tr>

View Replies View Related

Java Web Server - Display HTML Pages

Nov 7, 2014

I have a server written in java and can display html pages. but when i try to add css to the page the server doesnt use it.(not my code). Do you have to flag the browser to use css or something?

public class SimpleWebServer extends Thread {
public static final String VERSION = "SimpleWebServer";
public static final Hashtable MIME_TYPES = new Hashtable();
static {
String image = "image/";
MIME_TYPES.put(".gif", image + "gif");
MIME_TYPES.put(".jpg", image + "jpeg");

[Code] .....

View Replies View Related

Array In Class Calculations Out Of Bounds?

Mar 26, 2014

It seems that all of my arrays in the class Calculations are out of bounds, and I do not seem to know why.

Java Code:

/**
public class DataAnalyzer
{
public static void main (String[] args) {
//This creates an instance of ReadFiles
ReadFiles aReadFiles = new ReadFiles();
Calculations aCalculations = new Calculations();

[code]....

View Replies View Related

What Code To Manipulate Strings To Do Calculations

Dec 4, 2014

I have some data files that take this form:

D14
J3
N1
a26

[code]...

I also have this code that takes the file, goes through each line using a loop and counts the total of all the integers on each line, it also then loops and takes each integer on each line and divides it by the total calculated in the previous loop but I don't know what code to manipulate the strings to do these calculations. After these calculations I want to write the updated values to the text file I originally took the data in from. So as an example the total I already for this file to be '232' so the first line would be D 0.06 because 14/232 = 0.06034482758 and rounded to 2 decimal points is 0.06.

import java.io.File;
import java.io.FileReader;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.util.Scanner;
public class Normalise {
private static Scanner scanner;
//private static PrintWriter out;

[code]....

View Replies View Related

Using Two Dimensional Arrays To Make Calculations

May 10, 2014

I am having problems figuring out how to make calculations using a two dimensional array. The problem is finding the distance of a projectile given the launch velocity and angle. The equation is x = v^2*sin(2theta)/g. I understand how to implement this equation using the toRadians() and Sin() methods. What I don't understand is how to calculate the distance values with a multi dimensional array.

double [][] data = { {20, 15},
{50, 35},
{80, 45},
{100, 65},
{150, 85},
{10, 50},
{110, 8}};

My array has the velocities on the left and angles on the right. I tried using nested loops but I don't know how to access the two pieces of data at a time which I need.

View Replies View Related

RMI With Doing Calculations Across A Server / Client Platform

Apr 6, 2014

It's an RMI program that has to be able to return the mean, mode and median of a set of numbers.It's composed of 4 classes; a client, an implementation class (with the math), an Interface, and a server class.

import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.io.*;
 
[code]....

View Replies View Related







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