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.

Lv 31,400 points

Joseph Chang

Favorite Answers8%
Answers242
  • Increasing Capacitance in an RC circuit while keeping the same voltage?

    What happens to Vout in an RC circuit if you put in larger and larger capacitors? I was graphing this on PSpice and it shows Vout becoming flatter and smaller (closer to zero). Why is this?

    Circuit

    https://upload.wikimedia.org/wikipedia/en/4/42/Fir...

    1 AnswerEngineering4 years ago
  • PHP vs. Python vs. Ruby?

    A team of interns and I are making a website hosted by a desktop (no internet required). It will be for a vending machine and the website will be very much like a online store with a shopping cart. Is PHP, Python, or Ruby most suited for our needs?

    4 AnswersProgramming & Design5 years ago
  • C Programming - How to input right about ./a.out?

    Hi all,

    I'm having trouble figuring out how to set parameters so you can read inputs right after ./a.out in unix. My instructor has not covered this, but it's in the homework.

    ex.

    ./a.out 2 4

    f(2,4) = 41

    1 AnswerProgramming & Design5 years ago
  • Java Static and Non-Static Error?

    The last line has an error.

    public class Player

    {

    public static final int ROCK = 1;

    public static final int PAPER = 2;

    public static final int SCISSORS = 3;

    public static final int LIZARD = 4;

    public static final int SPOCK = 5;

    public static final String DEFAULT_NAME = "CPU";

    public static final int DEFAULT_WINS = 0;

    private static int round;

    private String name;

    private int wins;

    public Player()

    {

    name = "John";

    }

    public Player(String playerName)

    {

    name = playerName;

    }

    public void setName(String name)

    {

    this.name = name;

    }

    public void incrementWins()

    {

    }

    public String getName()

    {

    return name;

    }

    public int getWins()

    {

    return wins;

    }

    public String toString()

    {

    return ("Name: " + name + ", Rounds: " + round + ", Wins: " + wins);

    }

    public boolean equals(Player otherPlayer)

    {

    return Player.equals(otherPlayer);

    }

    }

    I'm not sure why the equals method has the error... non-static method equals(Player) cannot be referenced from a static context.

    What am I doing wrong?

    2 AnswersProgramming & Design6 years ago
  • Java Compiler Errors?

    public class HandGamePlayer

    {

    public static final int ROCK = 1;

    public static final int PAPER = 2;

    public static final int SCISSORS = 3;

    public static final int LIZARD = 4;

    public static final int SPOCK = 5;

    public static final String DEFAULT_NAME = "CPU";

    public static final int DEFAULT_WINS = 0;

    private static int rounds;

    private String name;

    private int wins;

    public Player() //ERROR HERE: these two have the error, invalid method declaration. return type required. They are constructors though and don't have return types? Why does it give me this error?

    {

    name = "John";

    }

    public Player(String playerName) //ERROR HERE

    {

    name = playerName;

    }

    public void setName(String name)

    {

    this.name = name;

    }

    public void incrementWins()

    {

    }

    public String getName()

    {

    return name;

    }

    public int getWins()

    {

    return wins;

    }

    public String toString()

    {

    return ("Name: " + name + ", Rounds: " + rounds + ", Wins: " + wins);

    }

    public boolean equals(Player otherPlayer)

    {

    return Player.equals(otherPlayer);

    }

    public static char getRoundStatus(int sign1, int sign2)

    {

    if(sign1 > sign2)

    {

    return 'W';

    round++;

    }

    else

    {

    return 'L';

    round++;

    }

    }

    }

    }

    }

    1 AnswerProgramming & Design6 years ago
  • The System Could not Find a Suitable Main Method?

    Everything is compiled, but I get the error:

    The System could not find a suitable Main Method. How do I fix this?

    public class CalculatingStudentGrade

    {

    public static void main(String[] args)

    {

    int quizScore1, quizScore2, quizScore3, midtermScore, finalScore, gradeScore;

    char letterGrade;

    StudentRecord sr = new StudentRecord();

    Cs111.printHeader(8, "4/1/2015");

    quizScore1 = Cs111.readInt("Enter Quiz 1 score:", 0, 10);

    quizScore2 = Cs111.readInt("Enter Quiz 2 score:", 0, 10);

    quizScore3 = Cs111.readInt("Enter Quiz 3 score:", 0, 10);

    midtermScore = Cs111.readInt("Enter Midterm score: ", 0, 100);

    finalScore = Cs111.readInt("Enter Final score: ", 0, 100);

    quizScore1 = sr.getQuizScore1();

    System.out.println("Quiz 1: " + quizScore1);

    quizScore2 = sr.getQuizScore2();

    System.out.println("Quiz 2: " + quizScore2);

    quizScore3 = sr.getQuizScore3();

    System.out.println("Quiz 3: " + quizScore3);

    midtermScore = sr.getMidtermScore();

    System.out.println("Midterm: " + midtermScore);

    finalScore = sr.getFinalScore();

    System.out.println("Final: " + finalScore);

    sr.studentRecord(quizScore1, quizScore2, quizScore3, midtermScore, finalScore);

    gradeScore = sr.getGradeScore();

    System.out.println("GradeScore: " + gradeScore);

    letterGrade = sr.getLetterGrade();

    System.out.println("Letter Grade: " + letterGrade);

    }

    }

    1 AnswerProgramming & Design6 years ago
  • Java Creating Objects for Methods?

    If I create the following...

    StudentRecord sr = new StudentRecord();

    sr.method();

    ... would sr have to be declared before this? If so, how?

    2 AnswersProgramming & Design6 years ago
  • Java Creating Objects for Methods?

    I asked my instructor about my code and he replied...

    All of your method calls for student grade must be called on an object! create a StudentRecord object and then call all the methods you have below.

    I'm confused. How do you call your method as an object?

    1 AnswerProgramming & Design6 years ago
  • Question about constructors in Java?

    Can someone give the a precise explanation about constructors in Java? I read through my textbook and couldn't understand it. I also didn't understand my teacher's explanation. It's supposed to initialize?

    1 AnswerProgramming & Design6 years ago
  • Java Help!?

    Can someone help me with these errors? I'm new to using methods in programs and keep getting compiler errors.

    import java.util.Scanner;

    import java.util.Scanner;

    public class MenuProgram

    {

    public static void main(String[] args)

    {

    double avg;

    Cs111.printHeader(6, "3/15/2015");

    System.out.println("Welcome User!");

    System.out.println("Main Menu");

    System.out.println("A: Tell me a joke");

    System.out.println("B: Tell me average of int and double");

    System.out.println("X: Exit program");

    System.out.println("");

    Cs111.readChar("Enter choice:", Scanner keyboard, "ABX"); //ERROR

    if(input == A)

    {

    System.out.println("What does a mechanic wear?");

    System.out.println("A tire!");

    }

    else if(input == B)

    {

    Cs111.readInt("Enter int:", Scanner keyboard, -1000000000, 1000000000); //ERROR

    Cs111.readDouble("Enter double:", Scanner keyboard, -100000000, 1000000000); //ERROR

    avg = (numInt + numDouble) / 2;

    System.out.println(avg);

    }

    else

    {

    System.exit(0);

    }

    }

    }

    1 AnswerProgramming & Design6 years ago
  • Using methods in programs? Java help!?

    I created my methods in one file and now I want to use them in a program. Is this the proper way to call them in? It gives me a compiler error. What am I doing wrong?

    import java.util.Scanner;

    public class MenuProgram

    {

    public static void main(String[] args)

    {

    char input;

    int numInt;

    double numDouble, avg;

    Cs111.printHeader(6, "3/15/2015");

    System.out.println("Welcome User!");

    System.out.println("Main Menu");

    System.out.println("A: Tell me a joke");

    System.out.println("B: Tell me average of int and double");

    System.out.println("X: Exit program");

    System.out.println("");

    Cs111.readChar("Enter choice:", Scanner keyboard, int -1000000000, int 1000000000);

    if(input == A)

    {

    System.out.println("What does a mechanic wear?");

    System.out.println("A tire!");

    }

    else if(input == B)

    {

    Cs111.readInt("Enter int:", Scanner keyboard, double -100000000000, double 100000000000);

    Cs111.readDouble("Enter double:", Scanner keyboard, );

    avg = (numInt + numDouble) / 2;

    System.out.println(avg);

    }

    else

    {

    System.exit(0);

    }

    }

    }

    1 AnswerProgramming & Design6 years ago
  • Constants in Methods? Java Help!?

    I am writing a method to print a Header, but I need to write constants. Is it correct to write the constants in this way? It gives me a compiler error.

    import java.util.Scanner;

    public class Cs111

    {

    public static final String AUTHOR = Joseph Chang;

    public static final String COURSE = CS111 Intro to CS111;

    public static final String SECTION = F 9:05am-12:55pm;

    public static void printHeader (int homework, String dateLastModified) //CONVENTION: camelNotation

    {

    System.out.println("/********************************************");

    System.out.println("* AUTHOR: " + NAME);

    System.out.println("* COURSE: " + COURSE);

    System.out.println("* SECTION: " + SECTION);

    System.out.println("* HOMEWORK #: " + homework);

    System.out.println("* LAST MODIFIED: " + dateLastModified);

    System.out.println("********************************************/");

    }

    1 AnswerProgramming & Design6 years ago
  • Making college portal accounts?

    Do I have to make these portal accounts for every single college I applied to in order to see if I've been accepted?

  • Format Specifiers in Java?

    I was wondering why this is correct...

    System.out.printf("Number or A's = %d which is %.1f.%%.%n", gradeA, percentA);

    and not this

    System.out.printf("Number or A's = %d which is %.1f.%.%n", gradeA, percentA);

    I don't see why there needs to be a second % symbol. In my textbook, it doesn't hav ethe extra %. Why is it there?

    1 AnswerProgramming & Design6 years ago
  • Formatting in Java?

    I am having trouble formatting the outputs at the end to one decimal place.

    import java.util.Scanner;

    public class OrganizingGrades

    {

    public static void main(String[] args)

    {

    int gradeA, gradeB, gradeC, gradeD, gradeF, gradeTotal, gradeInput;

    double percentA, percentB, percentC, percentD, percentF;

    Scanner keyboard;

    gradeA = 0;

    gradeB = 0;

    gradeC = 0;

    gradeD = 0;

    gradeF = 0;

    gradeTotal = 0;

    ...

    System.out.println("ERROR: Not a valid grade.");

    }

    else if (gradeTotal == 0)

    {

    System.out.println("No grades entered.");

    }

    else

    {

    percentA = ((double) gradeA / (double) gradeTotal) * 100;

    percentB = ((double) gradeB / (double) gradeTotal) * 100;

    percentC = ((double) gradeC / (double) gradeTotal) * 100;

    percentD = ((double) gradeD / (double) gradeTotal) * 100;

    percentF = ((double) gradeF / (double) gradeTotal) * 100;

    System.out.println("Total number of grades = " + gradeTotal);

    System.out.printf("Number or A's = " + gradeA + " which is %.1f.%\n", percentA);

    System.out.printf("Number or B's = " + gradeB + " which is %.1f.%\n", percentB);

    System.out.printf("Number or C's = " + gradeC + " which is %.1fn%\n", percentC);

    System.out.printf("Number or D's = " + gradeD + " which is %.1f.%\n", percentD);

    System.out.printf("Number or F's = " + gradeF + " which is %.1f.%\n", percentF);

    }

    }

    }

    2 AnswersProgramming & Design6 years ago
  • Formatting in Java?

    Is this the correct way to format to one decimal place? I keep getting weird results.

    System.out.println("Total number of grades = " + gradeTotal);

    System.out.printf("Number or A's = " + gradeA + " which is %.1f.%n%", percentA);

    System.out.printf("Number or B's = " + gradeB + " which is %.1f.%n%", percentB);

    System.out.printf("Number or C's = " + gradeC + " which is %.1f.%n%", percentC);

    System.out.printf("Number or D's = " + gradeD + " which is %.1f.%n%", percentD);

    System.out.printf("Number or F's = " + gradeF + " which is %.1f.%n%", percentF);

  • Help with JAVA?

    CODE is repeated for 8 tosses [Project 1]

    import javax.swing.JOptionPane;

    public class CalculatingCoinTossChance

    {

    public static void main(String[] args)

    {

    int numHeads, numTails;

    double percentHeads, percentTails;

    char firstToss, secondToss, thirdToss, fourthToss, fifthToss, sixthToss, seventhToss, eighthToss;

    numHeads = 0;

    numTails = 0;

    firstToss = JOptionPane.showInputDialog(null,"FirstToss: Enter 'h' for heads or 't' for tails.").charAt(0);

    if(firstToss == 'h' || firstToss == 'H')

    {

    numHeads++;

    }

    else

    {

    numTails++;

    }

    The question asks...

    Write a program that will print out the statistics for eight coin tosses. The user will input either an H for heads or a T for tails for the eight tosses. The program will print out the total number and percentages of heads and tails. Use the increment operator to increment the number of tosses as each coin is output. Use JOption for Input.

    Project 1: Solve the above problem with the branching material covered thus far (basics, scanner, branching).

    Project 2: Solve the above problem WITHOUT branching (yes its possible! HINT: think of what characters are actually stored as...)

    I solved project 1 above, but can't figure out how to solve project 2.

    Any help appreciated!

    2 AnswersProgramming & Design6 years ago
  • Java Coin Toss Problem (Update 2)?

    I am basically using this code...

    import javax.swing.JOptionPane;

    public class CalculatingCoinTossChance

    {

    public static void main(String[] args)

    {

    int numHeads, numTails;

    double percentHeads, percentTails;

    char firstToss, secondToss, thirdToss, fourthToss, fifthToss, sixthToss, seventhToss, eighthToss;

    numHeads = 0;

    numTails = 0;

    firstToss = JOptionPane.showInputDialog(null,"FirstToss: Enter 'h' for heads or 't' for tails.").charAt(0);

    if(firstToss == 'h' || firstToss == 'H')

    {

    numHeads++;

    }

    else

    {

    numTails++;

    }

    It is repeated for 8 tosses. Now, my question is, how to do this without using for, switch-case, if-else, or any other branching. I'm a beginner by the way.

    This is what we've learned so far: basics, scanner, loops, branching.

    The assignment asks:

    Write a program that will print out the statistics for eight coin tosses. The user will input either an H for heads or a T for tails for the eight tosses. The program will print out the total number and percentages of heads and tails. Use the increment operator to increment the number of tosses as each coin is output. Use JOption for Input.

    Project 1: Solve the above problem with the branching material covered thus far.

    Project 2: Solve the above problem WITHOUT branching (yes its possible! HINT: think of what characters are actually stored as...)

  • Java Coin Toss Problem (Update)?

    I am basically using this code...

    import javax.swing.JOptionPane;

    public class CalculatingCoinTossChance

    {

    public static void main(String[] args)

    {

    int numHeads, numTails;

    double percentHeads, percentTails;

    char firstToss, secondToss, thirdToss, fourthToss, fifthToss, sixthToss, seventhToss, eighthToss;

    numHeads = 0;

    numTails = 0;

    firstToss = JOptionPane.showInputDialog(null,"FirstToss: Enter 'h' for heads or 't' for tails.").charAt(0);

    if(firstToss == 'h' || firstToss == 'H')

    {

    numHeads++;

    }

    else

    {

    numTails++;

    }

    It is repeated for 8 tosses. Now, my question is, how to do this without using for, switch-case, if-else, or any other branching. I'm a beginner by the way.

  • Java Coin Toss Program (HELP!)?

    So, I need to write a coin toss program that does n't include branching (if-else, switch-case, etc.) I've tried over and over again and still have no idea how to do it. Do you need to use the letters 'H' and 'T' as they are stored?

    1 AnswerProgramming & Design6 years ago