Creating Program That Will Estimate Child Height Based On Height Of Parents

Jun 19, 2014

I am trying to create a program that will estimate a child height based on the height of the parents. It should ask the user to enter a String representing the gender, so m or M for a male and f or F for a female. The program must handle both upper or lower case gender entries. I need it to ask the user for the height of both parents in two parts:

1. for Feet and store in an int variable.
2. for inches and store and int variable.

So for example if the father is 6' 2'', the user would enter 6 when asked for feet and 2 when asked for inches. Convert the height of the each parent to inches. hint 12" in one foot.

Apply the following formulas based on gender (must use an if statement(s)):

Hmale_child = ((Hmother * 13/12) + Hfather)/2
Hfemale_child = ((Hfather * 13/12) + Hmother)/2

I cannot figure out what is missing from my code

<import java.util.Scanner;
public class ChildHeight
{
public static void main(String[] args) {
Scanner scannerObject = new Scanner(System.in);
String gender;
String male;
String female;

[Code] ....

View Replies


ADVERTISEMENT

Significant Of Object With Parents / Child

Sep 29, 2014

Below mentioned classes, create object system accept in both way so what is it significant.

============
ABC obj = new Test();

Test obj = new Test();
==================

--file ABC class

class ABC{   public void disp()   {   System.out.println("disp() method of parent class");   }  
public void abc()   {   System.out.println("abc() method of parent class");   }  }

--file Test class

class Test extends ABC{   public void disp(){   System.out.println("disp() method of Child class");   }  
public void xyz(){   System.out.println("xyz() method of Child class");   }  
public static void main( String args[]) {   //Parent class reference to child class object 
ABC obj = new Test();  obj.disp();  obj.abc();   }}

View Replies View Related

JTable Height Should Fit To The Contents

Jul 24, 2014

I have a jTable with one or 40 rows in it.

The problem is, also when I have only one row in my jTable, the size of the jTable is a little more bigger than 40 rows.

How can I say the jTable, that she should scale to the size of the content?

I don`t want that the jTable is bigger than the content. For example the picture below:

View Replies View Related

Error When Trying To Set Changing Height Value From JFrame

Jun 24, 2014

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
public class Racquet {
private static final int WIDTH = 60;
private static final int HEIGHT = 20;

[code]....

The problem arises at the portion of the code that says

private int Y = game.getHeight() - 70;

I am not actually getting any compiler errors, but when I try to run the program, the command prompt pops up with this message:

Exception in thread "main" java.lang.NullPointerException
at Racquet.<init>(Racquet.java:19)
at Game.<init>(Game.java:10)
at Game.main(game.java:58)

What I want to do is make it so a GUI object that I created moves with the screen when I change the height. If I change it to private int Y = 330; the program works just fine.

View Replies View Related

GUI Bars - Increment Height By About 10 Pixels

Nov 12, 2014

So I'm trying to make a bar graph, each bar will increment the height by about 10 pixels. To do this, I'm making an array of bars. For some reason, using fillrect I cannot not increase the size more than 10 by 10, if I do, it will only show the 10 by 10. I want the bars to increase in height by 10 each time.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class AssortedAssortmentsOfSorts extends JFrame

[Code] .....

View Replies View Related

Java Computing Height Of Stack

Jun 2, 2015

Compute the height of a stack. Then determine whether that value is found in the stack element .

View Replies View Related

Finding Height Of Binary Search Tree?

Nov 13, 2014

So for an assignment I have to write a method that finds that height of this BST. I wrote this:

public int height(Node node)
{
if (node == null)
{
return 0;
}
else
{
return 1 +
Math.max(height(node.left),
height(node.right));
}
}

Which makes sense in my head. However, I added a couple of nodes in and realized I'm not sure how to call this method.

public static void main(String[] args) {
Tree<String, String> tree = new Tree<String, String>();
tree.add("A", "1");//some added stuff
tree.add("B", "2");
tree.add("C", "3");
tree.add("D", "4");
tree.add("E", "5");
tree.add("F", "6");
tree.add("G", "7");
tree.add("H", "8");
System.out.println(tree);
System.out.println(tree.height());

What exactly do I put in the parenthesis after tree.height? If you need to see more of my code I can do that but it is quite lengthy.

View Replies View Related

BorderLayout - How To Decrease The Height Of CENTER Position

May 5, 2014

Normally, the height of the CENTER component (or position) is greater than that of the NORTH and SOUTH components in a BorderLayout.

Is it possible to increase the size of the SOUTH component and decrease the size of the CENTER position because the jcomponents I want to add in the SOUTH component are bigger? or shall I have to change the layout and use some other layout?

View Replies View Related

Check If Height Is A Letter Between A To J - If Statement Always False

Jun 22, 2014

Why isn't heig ever equal to heightShipArray[count] no matter what letter I type in

String[] heightShipArray = {"A", "a", "B", "b", "C", "c", "D", "d", "E",
"e", "F", "f", "G", "g", "H", "h", "I", "i", "J", "j"};
boolean trueHeight = true; // checks if height is a letter between a-j/A-J
do {
Terminal.printLine("Input height with letters A to J");

[Code] ...

View Replies View Related

JavaFX 2.0 :: How To Dynamically Set Height Of Text Area

Jul 9, 2014

I have a requirement where in the content of the text area is dynamically populated from the database. I am able to successfully retrieve and display the data on the text area.
 
However when the content is too large, I am not able to dynamically set the height of the text area. When I try to display the same as a label, the display is flawless, dynamically sets the height as per the content. So, I tried to create a label, with same content and dynamically bind the height to the preferred height as below, but it doesn't work.
 
               // Generate User Note Description
                TextArea textArea = new TextArea();
                Label text = new Label();
             
               // SETTING THE TEXT TO A LABEL TO RETRIEVE THE HEIGHT
               text.setText(usrNotes.getNote().trim());
               
[Code] ....

View Replies View Related

JavaFX 2.0 :: How To Bind rows Height Of Two Tableview

Jan 20, 2015

I want to use to tableview one beside the other  so that they appear as a single table.  but I do not find how to bound the height rows of the two tableview.

View Replies View Related

Print Isosceles Triangle Depending On Variables Height

Nov 14, 2014

The program needs to print an isosceles triangle depending on variables Height, BorderSymbol and Interior symbol, how to do that. Here is what i did so far :

{
int height = 5;
int i = 0;
int count = 0;
String line = "";
 
[code]....

and the output is a blanc page nothing on the screen only spaces...

View Replies View Related

Draw V-shape Of Height N Entered By User With Stars

Apr 12, 2014

Am stuck in a problem that asks to write a program using nested for loops to draw a V-shape of height "n" entered by the user with stars .

View Replies View Related

Return Height Of Heap Of Sand In Bottom Of Hourglass

Nov 18, 2014

I am working on program and have been struggling to get around step 5 and 6 given below.

I have got on with the first couple of points. Where to begin with steps 5 and 6.

Java Code:

class Hourglass {
int height;
int bottomHalf;
public Hourglass (int h) {
height =h;
}
public Hourglass (){
height=3;
}

/*Write a method dropGrain that simulates one grain of sand falling into the bottom half of the Hourglass. If all the sand is already at the bottom before a grain is dropped, this method should cause the hourglass to be flipped, meaning that all the sand will be in the top again. Then, one grain of sand should fall. */

//Hint: this method can be quite short. All you need to do is update one attribute.

public void dropGrain(){
}

/*Write a method getHeapHeight() which returns the height of the heap of sand in the bottom of the hourglass.

Hint: a triangle of height h contains h*h grains (=1+3+5+...+h).

So determining the height when the amount of sand in the bottom half is a square (1,4,9,16,...) is easy. Think about what happens if the amount of sand is not exactly a square.*/

public int getHeapHeight() {
} mh_sh_highlight_all('java');

View Replies View Related

Calculating Area Of A Rectangle (height Multiply By Width)

Mar 19, 2014

I was suppose to create a simple Java program for calculating the area of a rectangle (height * width). Then check the user’s input, and make sure that they enter in a positive integer, and letting them try again if they enter in a negative number. (I'm not sure how to get them to try again.

I am suppose to use an "if" statements and indeterminate loops to achieve the solution. The program will have the following requirements:

1. Ask the user to enter in both a height and width (as an integer)
2. If the user enters in a negative number, display an error
3. If the user enters in a negative number, give them another chance to enter in the correct value
4. Calculate the area and display to the screen once two positive integers have been entered.

import java.util.Scanner;
public class RectangleAreaCalc
{
public static void main(String[] args)
{
int length;
int width;
int area;
 
[Code] ....

View Replies View Related

Java Window Settings - Open With Certain Width And Height

May 19, 2014

Any way to get my Java window to open with a certain width and height. I've been googling and haven't found to much valuable information. Here is what I have so far.

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class JavaWindow{
//Bring up the frame.
private JFrame f = new JFrame("JavaWindow");

[Code] ....

When you compile that it runs a small window. I would like that window to be bigger when the file opens.

View Replies View Related

ActionListener And GetActionCommand - Volume For Length / Width And Height?

May 17, 2013

I do not understand the getActionCommand and ActionListener concepts. This code does not resolve the volume for length, width, and height.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.awt.Container;
public class rectangularSolid extends JApplet implements ActionListener {

[Code] ....

View Replies View Related

Power Of Math - Calculate Volume Of A Cylinder By Asking User To Enter Height And Radius

Jan 29, 2015

How do you use power of math. I'm trying to write a calculator to calculate the volume of a cylinder by asking the user to enter the height and radius but when I use pow(2) it doesn't work. I imported java.lang.math class so i dont have to keep using math. for now my code runs just fine since I'm using radius * radius but I would really luv to use the power instead times each other when i have to use higher powers.

import java.util.Scanner;
import static java.lang.Math.*;
 public class Lab2 {
 public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
 
[Code] .....

View Replies View Related

Creating Tiled Based Map Game In Java?

May 10, 2014

I'm trying to create a tile based map JPanel but all I get is a white screen. I'm fairly new to the Java Swing and AWT package so I've been watching tutorials on YouTube so learn as much as I can. I don't know where I'm going wrong.

I've got three classes: Window.java which includes the Main method, Panel.java which is the JPanel and Tile.java to draw all the images into an array.

Window.java:

import javax.swing.JFrame;
public class Window extends JFrame {
public Window() {
setTitle("Project");
setSize(500, 400);
setLocationRelativeTo(null);

[Code] ....

Panel.java:

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
public class Panel extends JPanel implements Runnable {
private Image dbImage;

[code]....

I've checked through everything and still cannot find what I'm doing wrong. I did try different codes but I just got errors instead.

View Replies View Related

Creating Java Based Message Board?

Jan 4, 2015

I'm trying to create java based fairly simple forum.

The task is as following:-

• each user may post exactly one research topic;

• each each may see all research topics posted by other users;

• each each may read all messages contributed by all users on a particular research topic;

• each user may post a new message to contribute to the discussion on any of the topics posted.

Something like below:-

User topic: Intrusion Detection Systems
Posted by: John
[22/10/11 14:00] John wrote I am building a new IDS based
on neural networks. …………….Comments ………….?
[22/10/11 14:12] Kate wrote there could be too many false positives!

View Replies View Related

Creating Analog Clock Based On Certain Values

May 3, 2014

I'm working on a Java/Android program that takes a number input (for example, hour = 7 and minutes = 30 for 7:30AM), and then expresses it on an Analog clock. (hour hand pointing to 7 and minute hand pointing to 30 minutes) ...

How can this be done? Would I need a lot of image files? How to start ...

View Replies View Related

Creating New Constructor In Child Class Which Is Not In Parent Class

Feb 7, 2014

I've a parent class with a argument constructor like below(a sample code)

public class Parent {
Parent(String name) {
System.out.println(name);
}
public static void main(String[] args) {
}
}

Also I've child.class which extends Parent.class as shown below,

public class child extends Parent {
child(String name) {
super(name);
}
}

Now, I want create/modify the constructor which is in child, by taking "int i" as an input instead of "String name". How can I do that? Run time I want to execute child constructor not a parent constructor.

Condition is: Without making any changes to the Parent class

View Replies View Related

Creating A Dialog That Add TextField Dynamically Based On A Radio Button

Dec 12, 2014

What would be the simplest way of creating a Dialog that can add TextField dynamically based on whether a radio button option from the dialog box is selected. I thought of JOptionPane.showMessageDialog and adding a JComponent though I would not be able to add a TextField on the fly and I would not be able to add ActionListeners. The dialog would initially contain some radio buttons, labels and textfields.

View Replies View Related

Program That Links Several GUI As Menu Based Program

Dec 17, 2014

In a project for school. I have a program that links several GUI's as a menu based program. What I am trying to accomplish is when one of the previous GUI's is closed that it doesn't terminate the entire program. There is a lot of classes in the entire project so I'd prefer not to paste all the code here, but if it is necessary I will do so.

View Replies View Related

Using GUI Based Program To Communicate With Database

Apr 24, 2015

In a project we are using a gui based program to communicate with a database. My issue is the formatting within the GUI.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.*;

[code]...

This is what the gui looks like at run time. The question is how do I compact it so there is not so much space between the labels and the textArea. I've tried using different numbers on my GridLayout, but not a lot of success.

View Replies View Related

Creating A Program That Will Compile And Run Another Java Program

Feb 20, 2014

I'm creating a program that will compile and run another java program:Lets say I have a program in directory

D:HelloWorldsrc
and compiled program will be in
D:HelloWorldin
inside src and bin is a folder hello (that's a package)

package hello;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Hello World");
}
}

This program will be run by another program (that's the program that I am creating).Here is the code of my program:

package runnercompiler;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class RunnerCompiler {
 
[code]....

View Replies View Related







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