TRENDING NEWS

POPULAR NEWS

I Need Help With A Java Programming Question For My Homework. I Can

Need Help Java Program Homework?

"not allowed to if-else or loops statements"

Hmmmmm, if you can't use if-else, then you can use just if. No loops? What is this, Jupiter? Pluto? I'm sorry, but if this is a challenge question, then schools should be ban for giving students such assignment and messing up their brain. What if someone entered in 4857? The program would consists of 4000 lines of redundant code for such a simple program. However, this can be done with recursion, but I don't know if you've gotten into that yet. If not, then tell the teacher to stop smoking weed, marijuana, tobacco, vodka, tequila, rum, alcohol.

@modulo, impressive, I never thought of that. You deserve more than 1 thumbs up.

Help With Java Programming Homework please?

File Paint.java contains the partial program below, which when complete will calculate the amount of paint needed to paint the walls of a room of the given length and width. It assumes that the paint covers 300 square feet per gallon.

//************************************...
//File: Paint.java
//
//Purpose: Determine how much paint is needed to paint the walls
//of a room given its length, width, and height
//************************************...
import java.util.Scanner;

public class Paint
{
public static void main(String[] args)
{
final int COVERAGE = 300; //paint covers 300 sq ft/gal
//declare integers length, width, and height;
//declare double totalSqFt;
//declare double paintNeeded;
//declare and initialize Scanner object

//Prompt for and read in the length of the room

//Prompt for and read in the width of the room

//Prompt for and read in the height of the room

//Compute the total square feet to be painted--think
//about the dimensions of each wall

//Compute the amount of paint needed

//Print the length, width, and height of the room and the
//number of gallons of paint needed.
}
}

Save this file to your directory and do the following:

1. Fill in the missing statements (the comments tell you where to fill in) so that the program does what it is supposed to. Compile and run the program and correct any errors.
2. Suppose the room has doors and windows that don't need painting. Ask the user to enter the number of doors and number of windows in the room, and adjust the total square feet to be painted accordingly. Assume that each door is 25 square feet and each window is 10 square feet.

I just need the 2 programs that satisfy the questions asked.

Need help with Java programming?

I just started Java in school and it is my first programming language and for homework we have several programming problems to do that I need some help with. Here are the 2 problems.

1. Write an application that displays a frame containing two labels that display your first name and one for your last. Experiment with the size of the window to see the labels change their orientation to each other.

2. Write an application that prompts for and reads the user's first and last name (seperately). Then print a string composed of the first letter of the user's first name, followed by the first five characters of the user's last name, followed by a radom number in the range 10 to 99. Assume that the last name is at least five letters long. Similar algorithms are sometimes used to generate usernames for new computer accounts.

Any help would be greatly appreciate as I new to programming, especially Java and don't quite understand it fully yet.

Java Programming Question Please Help!!?

For my homework assignment i have to write a program that reads whether or not the inputted word is a palindrome or not. the code compiles but when the homework simulator runs its tests it gives me an error on the LAST test. If you could take a look and hopefully tell me what i am doing wrong i would appreciate it. Below is my code and the test results.

import java.util.Scanner;

public class PalFind
{
public static void main(String args[])
{
String original, reverse="";
Scanner in = new Scanner(System.in);

original = in.nextLine();

int length = original.length();

for ( int i = length - 1 ; i >= 0 ; i-- )
reverse = reverse + original.charAt(i);

if (original.equals(reverse))
System.out.println("Yes");
else
System.out.println("No");

}
}

and here is the testing outputs


Input test1.in
radar
pass        :    Yes
Input test2.in
abcdefghi
pass        :    No
Input test3.in
deed
pass        :    Yes
Input test4.in
racecar
pass        :    Yes
Input test5.in
Hanna
pass        :    No
Input test6.in
Hannah
fail; Actual: No
    Expected: Yes
Comparison failed.

I need help with my Java homework...?

Well, the array (v) can be accessed, element by element, by using squared brackets... like this:
v[1]
v[2]
v[3]

So, if you put in:
for (int i=0; i < v.length; i++)
System.out.println( "Value "+i+": "+v[i] );

That would result in:
Value 1: 0
Value 2: 5
Value 3: 10
Value 4: 1
Value 5: 3

And so on... That's how you access an array. Try integrating that with your program you have so far, and post back if you have any questions.

Best of Luck,
-Jess

Java Programming Help?

I am stuck on these few questions on my homework, and I have torn my book inside out X_x

Help appreciated =)

1. Give an example using Java syntax of how some class Y can be setup to inherit from some other class X.

(You would use the "super" right?)

5. Explain the difference between a JLabel, a JTextField, and a JTextArea.

(All I came up for this was that JTextArea uses plain text.)

6. Describe what must be done to make a GUI component like a JCheckBox appear in the top part of a JFrame. Use Java code in your explanation.

8. How does a flow layout manager organize GUI components?

(I know that it positions them horizontally, and with n columns, alogn with preserving the component size, but I feel like he wants more for this question...)

9. How would you make certain that only one of three JRadioButtons were selected at a time? Use Java code fragments to illustrate your answer.

TRENDING NEWS