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 188 points

cyimtyler2

Favorite Answers0%
Answers0
  • Am I using the java scanner right? (Nothing complicated just a simply little program)?

    Hi there, im new to the scanner class and was have a little bit of difficulty

    I thought I had the basic idea for it but that doesn't seem to be the case

    My code for this program is:

    private String myName;

    private int myNumCheesePizzas; //# of cheese pizzas

    private int myNumPeppPizzas; // # of pepperonini pizzas

    private int myNumVegPizzas; //# of veggie pizzas

    private int myCheeseSupply; // ounces of cheese

    private int myPepperoniSupply;// ounces of pepperoni

    private int myVeggieSupply; // ounces of veggies

    private double myRevenue; // dollars collected

    private double myOrigAcctBal;//original bank account balance

    private double myDoughSupply;

    private double myBuffChixSupply;

    private double myNumBuffChixPizzas;

    private String name;

    // constructor

    PizzaParlor2(String name)

    {

    Scanner scan = new Scanner("tye.txt");

    myName = name;

    myNumCheesePizzas = 0;

    myNumPeppPizzas = 0;

    myNumVegPizzas = 0;

    myCheeseSupply = scan.nextInt();

    myPepperoniSupply = scan.nextInt();

    myVeggieSupply = scan.nextInt();

    myRevenue = 0;

    myOrigAcctBal = 1000;

    myDoughSupply = 400;

    myBuffChixSupply = 300;

    myNumBuffChixPizzas = 0;

    }

    My text file (tye) is:

    350

    450

    600

    700

    And my error message is:

    Exception in thread "main" java.util.InputMismatchException

    at java.util.Scanner.throwFor(Scanner.java:840)

    at java.util.Scanner.next(Scanner.java:1461)

    at java.util.Scanner.nextInt(Scanner.java:2091)

    at java.util.Scanner.nextInt(Scanner.java:2050)

    at PizzaParlor2.<init>(PizzaParlor2.java:31)

    at PizzaTester2.main(PizzaTester2.java:14)

    If anyone could help me figure out what im doing wrong or offer advise to help me understand the scanner class that would be awesome

    Thanks,

    cyimtyler

    3 AnswersProgramming & Design1 decade ago
  • How to do you fix a computer when there are no restore points?

    (Just a note before I start: this pc is using windows vista basic)

    I have a computer that i need to fix and it is so screwed up that the C drive decided to make itself offline.

    Therefore i cannot do a system restore since there are no restore points.

    When i do try to make the C drive online it wants me to format it.

    I know that formatting that will delete everything off of it (everything!!!!).

    So first is there any suggestion so i don't have to format it?

    Second if i do format it, do the drivers reinstall themselves (the internal hardware to the computer)?

    Third when i got my computer formatted all my files were saved to a folders called "windows old"..... is it possibly that this will happen again?

    If anyone can help thanks

    ---Cyimtyler----

    6 AnswersLaptops & Notebooks1 decade ago
  • How to do you fix a computer when there are no restore points?

    (Just a note before I start: this pc is using windows vista basic)

    I have a computer that i need to fix and it is so screwed up that the C drive decided to make itself offline.

    Therefore i cannot do a system restore since there are no restore points.

    When i do try to make the C drive online it wants me to format it.

    I know that formatting that will delete everything off of it (everything!!!!).

    So first is there any suggestion so i don't have to format it?

    Second if i do format it, do the drivers reinstall themselves (the internal hardware to the computer)?

    Third when i got my computer formatted all my files were saved to a folders called "windows old"..... is it possibly that this will happen again?

    If anyone can help thanks

    ---Cyimtyler----

    1 AnswerSoftware1 decade ago
  • Whats the point of this?

    I have a simple code for a basic calculator program and im trying to figure out how to write methods. My code is:

    public class method {

    public static void main(String[] args) {

    System.out.print("Enter first num");

    double a = scan.nextDouble();

    System.out.print("Enter Second num");

    double b = scan.nextDouble();

    System.out.print("Enter Input");

    int input = scan.nextInt();

    double sum, dif, pro, div;

    if (input==1)

    {sum=a+b;

    System.out.print( sum);}

    if (input==2)

    {dif=a-b;

    System.out.print(dif);}

    if (input==3)

    {pro=a*b;

    System.out.print(pro);}

    if (input==4)

    {div=a/b;

    System.out.print(div);}

    }

    ////End of main String Args[]

    public static double add (double a, double b){

    double sum=a+b;

    return sum;

    }

    public static double sub (double a, double b) {

    double dif=a-b;

    return dif;

    }

    public static double mult (double a, double b){

    double pro=a*b;

    return pro;

    }

    public static double div (double a, double b){

    double div=a/b;

    return div;

    }

    ///end of methods

    (Sorry about the bad style this is how it came out on yahoo)

    Now my question is what is the point of the method? Doesn't my program just follow the rules of the if statement? Am i even using the method correctly or is this just a waste of code? If it is can someone tell me how to use it properly.

    Thanks

    Cyimtyler

    2 AnswersProgramming & Design1 decade ago
  • How to convert an arraylist to an array?

    I am new to java (5 months) and im trying to convert an arraylist with the Double (big D) data type into an array with a doubles data type (little d).

    My array list is:

    ArrayList<Double> grades = new ArrayList<Double>();

    and in the program i am using the .add method to add doubles to it.

    after that im trying to convert it into an array but im having a lot of trouble.

    If anyone could help that would be great. Also im new so complicated programming code might confuse me.

    Thanks

    1 AnswerProgramming & Design1 decade ago