Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Write a script that inputs a telephone number as a string in the form (555)555-5555. The script should use String method split to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. Display the area code in one text field and the seven-digit phone number in another text field.
1
Write a program that will calculate the area of a rectangle. Ask the user for two values(must be doubles), find the area, display the result.

2
Write a program that will calculate the average grade for 4 exams. Prompt the user for 4 exam grades, one at a time, then calculate the average and display the result.

3
Write a program that asks the user to enter a temperature in Fahrenheit degrees. The program should then convert this temperature into Celsius degrees rounded to the nearest tenth of a degree
How to create a Java program that gives off 10 alphabets (a-z) randomly? There must be at least 2 vowels too.
I wanted to know how put checkboxes in this code and if the code is right.

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class JMyNewHome extends JFrame implements ActionListener
{
static final double MODEL_ASPEN = 100000;
static final double MODEL_BRITTANY = 120000;
static final double MODEL_COLONIAL = 180000;
static final double MODEL_DARTMOOR = 250000;
static final double FEE_BEDROOM = 105000;
static final double FEE_CAR = 7775;

private JLabel lblModels = new JLabel("The models: ");
private JRadioButton[] models = new JRadioButton[] {
new JRadioButton("The Aspen"),
new JRadioButton("The Brittany"),
new JRadioButton("The Colonial"),
new JRadioButton("The Dartmoor")};

private JLabel lblBedrooms = new JLabel("The number of bedrooms: ");
private JRadioButton[] bedrooms = new JRadioButton[] {
new JRadioButton("Two"),
new JRadioButton("Three"),
new JRadioButton("Four")};

private JLabel lblGarage = new JLabel("The garage type: ");
private JRadioButton[] garage = new JRadioButton[] {
new JRadioButton("Zero-car"),
new JRadioButton("One-car"),
new JRadioButton("Two-car"),
new JRadioButton("Three-car")};

private JButton btnCalculate = new JButton("Calculate");
private JLabel lblTotal = new JLabel("Total fee is: ");
private JTextField txtTotal = new JTextField(10);

public JMyNewHome()
{
super("My New Home");

setLayout(new GridLayout(4, 1));

// add models
JPanel pnModels = new JPanel();
pnModels.setLayout(new FlowLayout());
pnModels.add(lblModels);
ButtonGroup groupModels = new ButtonGroup();
for (int i = 0; i < models.length; i++)
{
pnModels.add(models[i]);
groupModels.add(models[i]);
}
models[0].setSelected(true);
add(pnModels);

// add bedrooms
JPanel pnBedrooms = new JPanel();
pnBedrooms.setLayout(new FlowLayout());
pnBedrooms.add(lblBedrooms);
ButtonGroup groupBedrooms = new ButtonGroup();
for (int i = 0; i < bedrooms.length; i++)
{
pnBedrooms.add(bedrooms[i]);
groupBedrooms.add(bedrooms[i]);
}
bedrooms[0].setSelected(true);
add(pnBedrooms);

// add garage type
JPanel pnGarage = new JPanel();
pnGarage.setLayout(new FlowLayout());
pnGarage.add(lblGarage);
ButtonGroup groupGarage = new ButtonGroup();
for (int i = 0; i < garage.length; i++)
{
pnGarage.add(garage[i]);
groupGarage.add(garage[i]);
}
garage[0].setSelected(true);
add(pnGarage);

// add result panel
JPanel pnResult = new JPanel();
pnResult.setLayout(new FlowLayout());
pnResult.add(btnCalculate);
pnResult.add(lblTotal);
pnResult.add(txtTotal);
add(pnResult);

btnCalculate.addActionListener(this);

setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(600, 250);
}

public void actionPerformed(ActionEvent e)
{
double total = 0;
if (models[0].isSelected())
total += MODEL_ASPEN;
else if (models[1].isSelected())
total += MODEL_BRITTANY;
else if (models[2].isSelected())
total += MODEL_COLONIAL;
else
total += MODEL_DARTMOOR;

if (bedrooms[0].isSelected())
total += 2 * FEE_BEDROOM;
else if (bedrooms[1].isSelected())
total += 3 * FEE_BEDROOM;
else
total += 4 * FEE_BEDROOM;

if (garage[1].isSelected())
total += FEE_CAR;
else if (garage[2].isSelected())
total += 2 * FEE_CAR;
else if (garage[3].isSelected())
total += 3 * FEE_CAR;

// output to text field
txtTotal.setText(String.format("$%.2f", total));

}

public static void main(String[] args)
{
new JMyNewHome().setVisible(true);
}



}imp
I wanted to know if this code was right and if not what needs to be fixed?
public class Time
{
public static void main(String[] args)
{
int Time = 197;
int hours=3;
int minutes=17;
{
int hours =3;
int left = 17;
System.out.println("197 minutes is 3 hours and 17 minutes");
} // end class Time
}
I am having a hard time with questions 6a and 6b. 6a. I have to write a class that declares a variable named minutes, which holds minutes worked on a job, and assign a value. Display the value in hours and minutes; for example, 197 minutes becomes 3 hours and 17 minutes. Be sure to use a named consant where appropriate. 6b. Write an interactive version of the Time class that accepts the minutes worked from a user. How do I do these questions? I am very confused on how to do them. Needed basic code help.
How to write a algorithm that allows you to create a player for a prime game?
Can I add an academic video to help the programmer in doing my assignment?
LATEST TUTORIALS
APPROVED BY CLIENTS