Programming About Finding Triangle

Nov 25, 2014

class triangle
{
public static void main (String[] args)
{
System.out.println("Provide three side lengths - 000 to terminate.");
int a = In.getInt();
int b = In.getInt();
int c = In.getInt();
 
[code]....

My problem is that when I enter 5,2,5 it should be isosceles and acute but it comes out as isosceles and obtuse, and when I type 5,5,5 it comes out equilateral and right. The only one that works is if I enter 3,5,4 it will come out as scalene and right. I been at this for a while and my math looks correct.

View Replies


ADVERTISEMENT

Returns Area Of Triangle / Unless Triangle Not Value So Return String?

Dec 28, 2014

I'm doing a problem where the area of a triangle is returned (if valid). However, I want to return a message (i.e. 'triangle is not valid) if the triangle is invalid.

I'm not sure how to go about to doing this as my method (called area) will only let me return doubles. Possible to return a string in an else within my area method?

public class MyTriangle {
public static void main(String[] args) {
//triangle is valid if the sum of any two sides is bigger than the third
System.out.println(isValid(3, 4, 5));
System.out.println(area(543, 4, 5));

[Code] ...

View Replies View Related

How To Cut IDE Out Of Programming

Nov 17, 2014

I'm just trying to learn how to cut the IDE out of my programming.I've added C:Program FilesJavajdk1.7.0_55in to the environment variables (path), am navigating to the src folder where my java class exists in cmd prompt, and then typing "javac CaesarCipher.java", but its complaining that it can't find the file.

Is the problem something to do with the relative address of the compiler to the file it needs to run? Just a stab in the dark on my part. Or do I have to add the JRE path as well as the compiler?

View Replies View Related

Swing GUI Programming

Jan 6, 2014

I find myself asking these two questions because I see them as relating. First question is; I always write

Java Code: f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mh_sh_highlight_all('java');
(where f is a JFrame object)

to set the close for the JFrame. What I don't get about this is what is going on in the parenthesis. I looked in the Java Documentation, and it says an int goes inside. In that case, I don't really get what the word JFrame is doing there. Overall, please explain what is inside the parenthesis of that line and why it has to be there.The second question is a generic question. I notice a lot of times an object will be created, and as its parameter, you will have to instantiate an object. an example would be

Java Code: Class f = new Class(new Object) mh_sh_highlight_all('java');

What does it mean when an object gets created inside of a new object? Why is putting Java Code: new Object mh_sh_highlight_all('java');
ever necessary when concerning the two parenthesis?

View Replies View Related

UDP Server Programming In Java

Apr 15, 2015

The goal is as follows: Write a UDP 'CompressionServer' that will take input from the user until it sees a "magic string" at which time it will create a compressed and uncompressed version of the file in the file system.

So, I need to integrate the following "Zip" code in to my UDP server code (which already creates the uncompressed file)... That is where I am stuck at now. My first few attempts had the Zip code after I write to "fout" but that failed to create a ZIP file.

I guess the main point here is what are the key pieces of the ZIP code that I should include and what would be the best spot to place them in my server code...

Zip Code:

import java.io.*;
import java.util.zip.*;

public class Zip {
static final int BUFFER = 2048;
public static void main (String argv[]) {
try {
String fileInput = argv[0];
String fileOutput = argv[1];

[Code] ....

View Replies View Related

Programming LightsOut Game

May 3, 2014

I'm having problems programming the LightsOut game. I made a 5*5 matrix and filled it in with 1's and 0's, where 1 means on and 0 is off, they should be placed randomly. The player can choose a field, for example "A2", and the matrix should change according to the input. My problems are how can I choose a field ? How can I display the new matrix after playing the first step and so on?

PS: I'm using the console because I'm still not good with JOptionPane commands.This is my code for the Game:

public class TestLightsOut {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[][] blocks = new int[5][5];
String[] letters = { "A", "B", "C", "D", "E" };
String[] numbers = { " ", " ", " ", " ", "1 ", "2 ", "3 ", "4 ", "5 " };
String[] line = { " ", " ", "_", "_", "_", "_", "_", "_", "_",
"_", "_", "_", "_" };

[code]...

View Replies View Related

Difference Between Algorithm And Programming

Feb 21, 2014

What is difference between algorithm and programming?How to develope algorithm knowledge?

View Replies View Related

Programming To Registry - Preferences API

Feb 17, 2014

I'm learning Java and came across saving user preferences. As I was learning I also learned about object serialization and File input/output. I've heard that the windows registry can be a problem because it can quickly become a dumping ground for uninstalled programs. So my question is why should I use the Preferences API? and is it really good practice to program to the registry for saving information? I'd also like to be in good standing towards the programs I write so if it is common practice to write to the Registry how exactly would I manage the information that I dump into the Registry?

View Replies View Related

Java Programming - Coins In A Jar

Apr 3, 2014

We are working with Java and Eclipse..One of the assignments asks to "Write an application that determines the number of coins in a jar and prints out the total in dollars and cents. Read integer values that represents the number of quarters, dimes, nickels and pennies. Use a currency formatter to print the output."

View Replies View Related

Programming With Fingerprint SDK Java

May 1, 2014

I would like to bring a project in java program written by me, that interfaces with a fingerprint reader (already purchased, the reader U.are.U 4000b) and as I'm using fingerprint sdk sdk's Griaule.

View Replies View Related

Genetic Algorithm Programming

Oct 13, 2014

I am looking to program a simple genetic algorithm in Java but where to start.

" In a computer language of your choice, implement a simple genetic algorithm (GA). That is, write code for a generational GA which uses a binary encoding, tournament selection, single-point crossover and bit-wise mutation" ....

View Replies View Related

What Is Meaning Of OpenSource In Any Programming Languages

Dec 29, 2014

what is meaning of Open Source in programming lenguages?

I want to ask this question reagrding this context that if some company or some products that says "This is open source" all codes are available Then it it mean..

1)We can reuse,re produce,distribute this code,modify and sell it for commercial purpose?

I know there is license also attach with a OpenSource.

But What exactly meaning of OpenSource?

View Replies View Related

Common Characteristic In Programming Language

May 12, 2014

Which of these is not a real differentiator for programming languages:

a) Object-oriented / Process-Oriented
b) Interactive / Automated
c) Interpreted / Compiled
d) Strongly-Typed / Weakly-Typed
e) All of the above
f) B and C
g) B and D

Almost all support OOP, Interactive/Automated, Interpreted/Compiled but not sure about Strongly typed/Weakly typed.

View Replies View Related

Programming A Simple Password Checker

Aug 30, 2014

Use Java to write and run a simple console-window program for checking passwords. The program must satisfy the following requirements:

-When the program runs, it should first print its name, e.g., Password Checker
-The program should next prompt the user to enter a username, e.g.,

Please enter your username:

-The program should next prompt the user to enter a password, e.g., Please enter your password:
- If the user enters a correct password, i.e., one that matches an internal secret password, the program responds. You are approved by access control!, and quits.
-If the user enters an incorrect password, the program responds

Try again:
-If the user enters a correct password matching the secret one, the program responds. You are approved by access control!, and quits.
-If the user enters an incorrect password, the program responds

package class1;
import java.util.Scanner;
public class class1 {
public static void main(String[] args) {
// TODO Auto-generated method stub

[code]....

View Replies View Related

Where To Use Accept Routine In Socket Programming

Sep 2, 2014

i was reading my book when in a code,it used accept(),but it did'nt talk about it.would you explain to me where to use accept().(the chapter was about socket programming)

View Replies View Related

Programming Conway Game Of Life

Nov 17, 2014

I am having some trouble programming the Game of Life algorithm.

View Replies View Related

Use Java Programming For Image Processing

Feb 12, 2015

can we use java programming for image processing. if yes then how do we do it?

View Replies View Related

How To Build Triangle Using Loops

Jan 16, 2014

I need to build the triangle like below. How to solve this using loops.

*
* *
* * *
* * * *
* * * * *

View Replies View Related

Properties Of A Triangle - X And Y Coordinates

Oct 29, 2014

A triangle is defined by the x- and y- coordinates of its three corner points. Compute the following the following properties of a given triangle: the lengths of all sides, the angles at all corners, the perimeter and the area. The program must prompt a user for the point coordinates. I have created a class Triangle and a class TriangleSimulator, I am stuck and can't figure out why my program won't run correctly.

import java.util.Scanner;
public class Triangle {
Scanner in = new Scanner(System.in);
private int x1;
private int x2;
private int x3;

[Code] ....

View Replies View Related

Triangle Pattern (For Loop)

Feb 21, 2015

I'm trying to make a triangle which should look like this. But I cant seem o figure it out.

1
2 1
4 2 1
8 4 2 1
16 8 4 2 1
32 16 8 4 2 1
64 32 16 8 4 2 1
128 64 32 16 8 4 2 1

This is the code I have written so far.

public class TestProgram
{
public static void main(String[]args)
{
for (int columns=0; columns<=8; columns++)
{
for (int rows=columns; rows>=1; rows --)
{
System.out.print(rows+ " ");
}
System.out.println();
}
}
}

View Replies View Related

How To Get Main Triangle Program To Run

Oct 17, 2014

I am having trouble getting my main triangle program to run. My teacher gave us a sample program, so I tried running his, and it doesn't run either.

Here is the class:
 
import java.util.Scanner;
 public class ShelbyHarms_3_06_Triangle {
private double sideA, sideB, sideC; // Instance variables, numbers for area and perimeter
static Scanner console = new Scanner(System.in); // Establish keyboard
 
[Code] .....

My errors for the main program(the class has no errors) are:

helbyHarms_3_06.java:37: error: cannot find symbol
theSides.getSides();
^
symbol: variable theSides
location: class ShelbyHarms_3_06

[Code] ....

5 errors

View Replies View Related

Event Driven Programming / No Main Method

Jan 29, 2015

I'm reading a book titled 'Intro to Java Programming'. I understand all the Main Method stuff. I'm now reading a chapter that talks about event driven programming. I know how to do this in VBA and in C#, ut I can't figure out how this works in Java. Here's the sample code that I'm trying to run.

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;

[code]....

I'm using Net Beans IDE. When I paste that code into the IDE, I get all kinds of errors. Also, since there is no Main, I don't know how this is supposed to run. Java needs a Main Method for everything, I think. Does the Main call some kind of class?

View Replies View Related

File Transfer In Java Using Socket Programming

Apr 7, 2014

I have written a java code to transfer files from one server to another using the concept of socket programming. I got the codes from another java forum that meet my requirements. The program is said to transfer large sized files (like .mkv , .mprg movies) from one machine to another and can be used to transfer files of all formats. But after running the codes I found that the program is not able to transfer large sized files such as movies and even pdf of sizes 80mb or 111mb. When i transfer small sized files, it gets transferred and the output shows that. You can run the codes and observe it. But when i try to transfer large sized files, the program goes on running for hours. The large sized files are not getting transferred. The program has used bytebuffer but still this error occurs. The codes are as follows (I got them from this site [URL] ....)

**ClientMain.java**

import java.io.IOException;
import java.net.Socket;
public class ClientMain
{
private DirectoryTxr transmitter = null;
Socket clientSocket = null;

[Code] .....

1. ClientMain.java and DirectoryTxr.java are the two classes under client application.
2. ServerMain.java and DirectoryRcr.java are the two classes under Server application.
3. run the ClientMain.java and ServerMain.java simultaneously

Also specify the source directory, destination directory and host address of the machine in which server is running in the ClientMain.java (as per your computer). Here we are not specifying source file, instead a source directory or folder is specifying. So the entire files of source directory will be transferred.

View Replies View Related

Socket Programming - Serve All Network Protocols

Jan 13, 2014

I am new to java. I want to create a socket that can serve all the network protocols. Can we make such type of socket in java.

View Replies View Related

Java Programming Project Involving Get And Set Methods?

Apr 4, 2014

1. Modify the following class so that the two instance variables are private, there is a constructor that accepts both the player's name and sport and there are get and a set methods for each instance variable:

public class Player {
String name;
String sport;
}

2. You can pass an instance of this class to the JLabel constructor if you want to display text in the label.Select one:
a. myLabel
b. myText
c. String
d. JTextField
e. JLabelText

how to start making this work?cause i am not familiar with the terms here and want to complete this program and I am new to java programming?

View Replies View Related

Test Arithmetic Java Programming Error

Oct 13, 2014

I have written this program but I am seeing error when I compile this program ( javac TestArithmetic.java).

1)TestArithmetic.java:26 cannot find symbol

2)symbol: class Arithmetic

3)location: class TestArithmetic

4) Arithmetic ar = new Arithmetic(x1,x2,x3);

1)TestArithmetic.java:26 cannot find symbol

2)symbol: class Arithmetic

3)location: class TestArithmetic

4) Arithmetic ar = new Arithmetic(x1,x2,x3);

2 errors.

Code :

import java.util.*;
class TestArithmetic {
public static void main (String[] args){
float number;
Scanner console= new Scanner (System.in);
System.out.println("Enter first number");

[Code] .....

View Replies View Related







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