Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

kenzie
Need subwoofer suggestions to pair with my amp?
3 AnswersCar Audio5 years agoDefendants right to fair trial with media attention?
What can a court do before and during to allow a fair trial regarding media attention?
1 AnswerLaw & Ethics6 years agoJava write to text file?
I am trying to write name, age, salary and record to text file.
All variable are given value by input. My out.write line is not working.
class Text extends Writer
{ PrintWriter out = null;
public Text(String fileName) throws IOException
{
out = new PrintWriter (new FileOutputStream(fileName, true));
}
public void write(String name, int age, double salary, int record)
throws IOException
{
out.write(name, age, salary);
}
public void close()
{
out.close();
}
3 AnswersProgramming & Design8 years agoJava String Tokenizer?
Still having problems... I cannot figure out how to make my Complex parseComplex(Strign str) method work. I have to use string tokenizer. Can someone point me in the right direction on my code and what I need to return from that method? Thank You:)
package lab1;
//Program to add and multiply complex numbers.
//Lab #1 for cs258; uses a class that handles complex numbers (Complex.java).
import java.io.*;
public class Calculator
{ public static void main(String[] args)
{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Complex num1, num2, result = new Complex();
char op;
boolean more;
System.out.println("\nComplex number calculation program\n");
do
{ num1 = readComplex(in);
num2 = readComplex(in);
op = readChar(in, "Enter the operation '+, -, *, or /': ", "+-*/");
switch (op)
{ case '+': result = num1.add(num2);
break;
case '*': result = num1.product(num2);
break;
// case '/': result = num1.div(num2);
// break;
case '-': result = num1.minus(num2);
}
System.out.println(num1+" "+op+" "+num2+" = "+result);
more = (readChar(in, "Perform another calculation? (y/n): ", "yn") !='n');
} while (more);
System.out.println("\n\nCalculation program completed\n");
}
// Method to read a complex number
public static Complex readComplex(BufferedReader in)
{
String token;
while (true)
{ System.out.print("Enter a complex number: ");
try
{ token = in.readLine();
return Complex.parseComplex (token);
}
catch (Exception exception)
{ System.out.println("llegal Format - enter 'a+bi' and try again"); }
}
}
// Method to read the first character of a string
public static char readChar(BufferedReader in, String prompt, String chars)
{
String token;
char value;
while (true)
{ try
{ System.out.print(prompt);
token = in.readLine();
value = token.toLowerCase().charAt(0);
if (chars.indexOf(value)<0) throw new NumberFormatException();
return value;
}
catch (Exception exception)
{ System.out.println("Illegal - try again"); }
}
}
}
------------------------------------------------------------------------------------------------------------------------
package lab1;
import java.util.StringTokenizer;
public class Complex
{
private double real, imaginary;
public Complex()
{
real = 0;
imaginary = 0;
}
public Complex(double real, double imaginary)
{
}
// public String toString()
// {
// }
public Complex add( Complex c)
{
return new Complex
(real+c.real, imaginary+c.imaginary);
}
public Complex minus(Complex c)
{
return new Complex
(real-c.real, imaginary-c.imaginary);
}
public Complex product(Complex c)
{
return new Complex
((real*c.real)-(imaginary*c.imaginary), (real*c.imaginary)+(c.real*imaginary));
}
// public Complex div(Complex c)
// {
// return new Complex
// }
public static Complex parseComplex(String str)
{
StringTokenizer st = new StringTokenizer(str);
System.out.println(str);
// while(st.hasMoreTokens())
// {
double real = Double.parseDouble(st.nextToken());
System.out.println(real);
st.nextToken();
double imaginary = Double.parseDouble(st.nextToken());
System.out.println(imaginary);
System.out.println(st.nextToken());
// double real1 = Double.parseDouble(st.nextToken());
// double imaginary1 = Double.parseDouble(st.nextToken());
// System.out.println(real1);
// System.out.println(imaginary1);
//}
return null;
}
}
1 AnswerProgramming & Design8 years agoAdding Complex Number in Java?
I am trying to use String Tokenizer and add two complex numbers here are the methods I am having problems with. The user enters the complex numbers as a string, and then it is split into tokens.
public Complex add( Complex c)
{
return new Complex
(real+c.real, imaginary+c.imaginary);
}
public static Complex parseComplex(String str)
{
Complex token = null;
StringTokenizer st = new StringTokenizer(str);
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
// throw new NumberFormatException();
// throw new NoSuchElementException();
}
return token;
}
2 AnswersProgramming & Design8 years agoJava Eclipse Programming Help?
I am trying to finish one of my java classes. the overall project is a simple game. I cannot figure out why am am getting errors to complete statement, body, class, method, etc. Here it is, if you can help it would be greatly appreciated.
package game;
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.*;
public class Background extends JPanel implements Constants
{
private static final long serialVersionUID = 1L;
public final Color BACK_COLOR = Color.BLUE;
public double size, scale;
private Avatar avatar;
private int SPEED;
private ArrayList<Sprite> sprites;
public Background()
{
sprites = new ArrayList<Sprite>();
setBackground(BACK_COLOR);
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.addKeyEventDispatcher(new KeyEventDispatcher()
{
public boolean dispatchKeyEvent(KeyEvent event)
{
int x = 0, y ;
double angle = avatar.getAngle();
Point position = avatar.getPosition();
x = position.x;
y = position.y;
switch (event.getKeyCode())
{
case KeyEvent.VK_DOWN:
y += SPEED;
angle = 90;
break;
case KeyEvent.VK_UP:
y -= SPEED;
angle = 270;
break;
case KeyEvent.VK_LEFT:
x -= SPEED;
angle = 0;
break;
case KeyEvent.VK_RIGHT:
x += SPEED;
angle = 180;
break;
}
avatar.setParameters();
avatar.setPosition(new Point(x, y));
avatar.setAngle(angle);
if (!getBounds().contains(avatar.getBounds()))
{
Toolkit.getDefaultToolkit().beep();
avatar.restore();
repaint();
return true;
}
return true;
repaint();
reset(0);
avatarPanel.reset();
}
public void reset(int level){
int x, y, angle;
Sprite sprite = null;
sprites.clear();
int[] figures = FIGURES[level] ;
for (int type=0; type<figures.length; type++)
{
for (int figure=0; figure<figures[type]; figure++)
{
x = (int)(Math.random()*Game.APP_SIZE.width);
y = (int)(Math.random()*Game.APP_SIZE.height);
switch (type)
{
case 0:
sprite = new Mine(x,y);
break;
case 1:
sprite = new Shield(x, y);
break;
case 2:
sprite = new Predator(x, y);
break;
case 3:
sprite = avatar = new Avatar(x, y);
break;
}
double min = sprite.getMinScaleFactor();
double max = sprite.getMaxScaleFactor();
scale = Math.random()*(max-min)+min;
sprite.setScale(scale);
angle = (int)(Math.random()*360);
sprite.setAngle(angle);
sprites.add(sprite);
repaint();
}
}
}
public void paintComponent(Graphics g)
{
paintComponent(g);
for (Sprite s: sprites)
{
s.draw(g);
}
}
public void actionPerformed(ActionEvent event)
{
Sprite s;
Move move;
for (int i =0; i<sprites.size();i++)
{
s = sprites.get(i);
if(s instanceof Move)
{
move = (Move)s;
move.nextPosition(getBounds());
}
repaint();
}
}
}
}
}
1 AnswerProgramming & Design8 years agoCan someone give me a tab or sheet music for the lyrics:?
Looking for someone to write out a tab or sheet music for the lyric part of this song here http://www.youtube.com/watch?v=2yaRjWfwWPI
1 AnswerCelebrities8 years agoJava Programming Algorithm?
Goals: Implement searching algorithms and time them to see which approach is best.
Description
1. Create a new project called Lab8; the class files will comprise a package named Search. This project will be a Java Application, not a Java Applet. Make sure that you select the create Main Project check box after selecting file/new/Java Application. You won’t have to change the Project Properties.
2. This lab creates a GUI application that evaluates three search methods (linear, binary, and the built in Java collections search). A screen shot of my implementation follows.
3. My Implementation has three classes. These are Main, MainPanel, and Searcher.
4. This program randomly generates a set of strings where each string is a particular size. It then performs a series of search operations on the data and times how long it takes. The results show in the labels at the south side of the GUI panel.
5. The GUI structure is very similar to lab 7. You might review those instructions for hints. The main differences follow:
a. In this lab there is a drop down selection where the user selects number of searches to be done. There was no corresponding entry in lab 7.
b. The search type dropdown menu selections are linear, binary, and generic.
c. The Searcher class implements methods for each of the three search categories. These methods are presented in the week 7 slides.
d. The Searcher class has a String[] doSearch(int len, int n, int , int tries, int type) method, instead of String[] doSort(int len, int n, int type). In a loop, this method randomly picks a string from the data generated and then calls the appropriate search method.
2 AnswersProgramming & Design8 years agoWhich java method is affected?
class A
{ int i=1;
static int j = 3;
void m() { i = 5; }
static void m1() { j = 7; }
}
class B extends A
{ int i=2;
static int j = 4;
void m() { i=6; }
static void m1() { j = 8; }
}
In the main method we have statements
B b = new B();
A a = new B();
Answer the questions below, indicating the class method and variables affected.
a. Which method does a.m() call?
b. Which method does a.m1() call?
c. Which method does b.m() call?
d. Which method does b.m1() call?
e. Which variable does a.m() update?
f. Which variable does a.m1() update?
g. Which variable does b.m() update?
h. Which variable does b.m1() update?
1 AnswerProgramming & Design8 years agoJava Loop to add odd numbers?
I need to sum all odd numbers between 1 and 100 using a for loop, while loop, and do while loop. Help?
2 AnswersProgramming & Design8 years agoJava method to find days in month?
Write a method that prints the days in a particular month. It should have the following signature shown below. You can assume that any year evenly divisible by 4 is a leap year.
int daysInMonth(int month, int year)
4 AnswersProgramming & Design8 years agoHelp splitting my java code into several methods in same class?
I need help splitting my program in to separate methods all in one class. the program inputs the size of an array, find max min and average.
import java.util.Scanner;
import java.util.Arrays;
public class GradeArray
{
public static void main( String argv[] )
{
Scanner keyboard = new Scanner(System.in);
System.out.print( "How large do you want the array? " );
double[] theArray = new double[keyboard.nextInt()];
for( int i=0 ; i<theArray.length ; i++ )
{
System.out.print( "Enter value " + (i+1) + ": " );
theArray[i] = keyboard.nextDouble();
}
Arrays.sort(theArray);
System.out.println("The lowest is: " +theArray[0]);
Arrays.sort(theArray);
System.out.println("The highest is: " + theArray[theArray.length-1]);
double sum = 0;
double average = 0;
for (int i = 0; i < theArray.length; i++) {
sum += theArray[i];
}
average = sum / theArray.length;
System.out.println("The average is: " + average);
}}
2 AnswersProgramming & Design8 years agoJava Array Program (User entered length, high, low, avg)?
I need to write a java program that asks the user how many number will be in the list. The input is stored to an array list. The highest number, lowest number, average number is then found. There needs to be a method to get input, find high, find low, find average
1 AnswerProgramming & Design8 years agoIf and Else If Statement In Java Problem?
Program inputs the type of package, shipping option, and weight. The problem is in the else if (tos == 2){ section. When tos = 2 or three it uses zero for cost, if I do not declare that cost = 0 in my variables I get a variable may not have been initialized error. Any Ideas?
-------------------------------------
import java.util.*;
import java.text.*;
public class ExpressimoDeliveryService{
public static void main (String[] args){
Scanner scanner = new Scanner(System.in);
double top,
tos,
cost = 0,
pounds,
ounces,
weight;
DecimalFormat df = new DecimalFormat("'$'0.00");
System.out.println("-------------------------------------------------");
System.out.println("ExpressimoDeliveryService");
System.out.println("-------------------------------------------------");
System.out.println("Enter The Weight of Package: (Pounds then Ounces)");
System.out.println(" Pounds: ");
pounds = scanner.nextInt();
System.out.println(" Ounces: ");
ounces = scanner.nextInt();
System.out.println("Select The Type of Package: ");
System.out.println(" 1 For A Letter ");
System.out.println(" 2 For A Box ");
top = scanner.nextInt();
System.out.println("Select The Type of Service: ");
System.out.println(" 1 For Next Day Priority ");
System.out.println(" 2 For Next Day Standard ");
System.out.println(" 3 For 2-Day ");
tos = scanner.nextInt();
weight = 16 * pounds + ounces;
if (weight > 0){
if(top == 1){
if (tos ==1){
if (weight <= 8){
cost = 12;
}
if (weight > 8){
System.out.println("Package Is Too Large, Select Box Package Option");
}
}
else if (tos == 2) {
if (weight <= 8){
cost = 10.5;
}
if (weight > 8){
System.out.println("The Package Is Too Large To Ship With This Method");
}
}
else if (tos == 3){
if (weight <= 8){
System.out.println("The Package Can Not Use This Type of Service");
}
if (weight > 8){
System.out.println("The Package Can Not Use This Type of Service");
}
}
}
if(top == 2){
if (tos == 1){
if (weight <= 8){
System.out.println("The Package Is Too Small To Use A Box");
}
if (weight > 8){
cost = 15.75 + (1.25)*((weight/16)-1);
}
else if (tos == 2){
if (weight < 8){
System.out.println("The Package Is Too Small To Use A Box");
}
if (weight > 8){
cost = 13.75 + (1)*((weight/16)-1);
}
}
else if (tos == 3){
if (weight < 8){
System.out.println("The Package Is Too Small To Ship With This Method");
}
if (weight > 8){
cost = 7 + (0.5)*((weight/16)-1);
}
}
}
}
System.out.println("The Service Cost For This Package Is: " + df.format(cost));
}
else {
System.out.println("The Weight Of The Package is Invalid: Check Input");
}
}
5 AnswersProgramming & Design8 years agoJava Program Using Two Classes?
Here is my prompt:
Design and implement a class to represent a single multiple-choice question on an exam. Each question consists of a section that asks the question, and then four choices of answer, each of which is a letter followed by the answer. For example:
What type of method is typically declared as private and static?
Constructor
Instance
Class
Helper
The class should have attributes for the question, the four answers, and the correct response. An example call to a constructor for this class would be
ExamQuestion q17 = new ExamQuestion(“What type of method is typically declared as private and static?”, “Constructor”, “Instance”, “Class”, “Helper”, ‘d’);
The class should supply accessor methods that return each of the attributes as well as supply a method that prints the question on System.out in the format shown above.
Develop a separate driver class that could be used to test this class. This class should:
Create 2 instances of the Exam Question class, with two different questions (your choice of topic).
Display the first question, the four possible answers (using the ExamQuestion’s print method)
Get the user’s answer and display the correct answer.
Display the second question and its possible answers (using the ExamQuestion’s print method)
Get the user’s answer to the second question and display the correct answer.
1 AnswerProgramming & Design8 years agoIntro to Java Find Least Amount of Boxes?
Trying to complete a step in programming class. Program takes user inputted value for number of coffee bags wanted. Must find how many of each box must be used to use least amount of boxes. Large and Medium must be full. Small can be partially full. Large holds 20, medium holds 10 and small holds 5. This is my code so far. Thinking it is something in java.Math.* that I am not using. Thanks.
import java.util.*;
import java.text.*;
import java.math.*;
public class MyJava1{
public static void main (String[] args){
Scanner scanner = new Scanner(System.in);
int amountordered;
int
largeamount,
mediumamount,
smallamount;
double
largeprice=1.60,
mediumprice=1.00,
smallprice=0.60;
double
totalcost,
largecost,
mediumcost,
smallcost;
DecimalFormat d = new DecimalFormat("'$'0.00");
DecimalFormat m = new DecimalFormat("0.00");
System.out.println("Enter Order Amount: ");
amountordered = scanner.nextInt();
largeamount = amountordered/20;
mediumamount = (amountordered - (largeamount*20))/10;
smallamount = ((amountordered) - (largeamount*20) - (mediumamount*10))/5;
System.out.println(largeamount);
System.out.println(mediumamount);
System.out.println(smallamount);
}}
2 AnswersProgramming & Design8 years agoRunning exe files with .bat file?
This is my .bat file for running multiple .exe files one after the other to speed up installing. I am trying to find out how to write the "location" of the file in my code so it runs the .exe at this point it splashes this on the screen, closes, and installs nothing....Help?
@Echo off
:Begin
start /wait /Software/7z920-x64.msi
start /wait /Software/audacity-win-unicode-1.3.12.exe
start /wait /Software/CamStudio20.exe
start /wait /Software/ccsetup304.exe
start /wait /Software/DragonSetupp.exe
start /wait /Software/FirefoxSetup4.0.exe
start /wait /Software/flashplayer64.exe
start /wait /Software/flashsquare64.exe
start /wait /Software/Foxit.exe
start /wait /Software/HandBrake.exe
start /wait /Software/installspeedfan443.exe
start /wait /Software/ccsetup304.exe
start /wait /Software/rcsetup140.exe
start /wait /Software/utorrent.exe
start /wait /Software/VLC.exe
start /wait /Software/ticonnect_eng.exe
start /wait /Software/SyncToyy.exe
start /wait /Software/SkypeSetupFull.exe
Start /wait /Software/SafeHouse.exe
start /wait /Software/picasa38-setup.exe
start /wait /Software/OpenDNSUpdater.exe
start /wait /Software/msgr22us.exe
start /wait /Software/OOo_3.3.0_Win_x86_install-wJRE_en-US.exe
:End
1 AnswerProgramming & Design1 decade agoI NEED HELP FINDING THE EQUATION FOR A COS GRAPH?
Need Help Urgently:
Find a model sinusoidal function for the following data-
maximum of 50 at 3 seconds
minimum of 25 at 8 seconds
I NEED HELP!!!!
1 AnswerHomework Help1 decade agoHow to upgrade an HP iPaq Pocket PC?
I have an HP iPaq Pocket PC with Microsoft Windows Mobile 2003 that I wanted to update to a current OS and install new applications on it. Windows Mobile or some form of Linux would be nice. It has bluetooth,infer red and wifi and new operating must support. More information is listed below:
HP iPAQ h4300 series
Agency Series PE2080B
Z125
1 AnswerPDAs & Handhelds1 decade agohow to calculate energy usage in physics?
how to calculate the calories needed to heat 500grams of water from 20 to 100 degrees celsius?
1 AnswerPhysics1 decade ago