Search:

Type: Posts; User: javaBoi

Search: Search took 0.09 seconds.

  1. Replies
    11
    Views
    1,958

    Re: Java Program: Falling Distance Problem

    Don't have time to look up for these errors, but--anyways--I actually figured it out. Thanks, I suppose.
  2. Replies
    11
    Views
    1,958

    Re: Java Program: Falling Distance Problem

    Falling Distance

    Time Distance
    (seconds) (meters)

    Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.Integer
    at...
  3. Replies
    11
    Views
    1,958

    Re: Java Program: Falling Distance Problem

    2921

    It prints out the string variables (which is fine), but then it gives me these compiler errors. Mind you, that's when I use the second line of code (which I currently have as a comment).
  4. Replies
    11
    Views
    1,958

    Re: Java Program: Falling Distance Problem

    Okay, I'm getting somewhere now. Here's what I have

    2919

    And just need to get it to look like this:

    2920

    I know the whole printf method to align everything, but I can't seem to get this...
  5. Replies
    11
    Views
    1,958

    Re: Java Program: Falling Distance Problem

    I was able to get the value of seconds to change (e.g. 1, 2, 3, 4, 5...10). How do I get the value to change for meters is the question I'm asking.
  6. Replies
    11
    Views
    1,958

    Re: Java Program: Falling Distance Problem

    All I had to do was include "=" to if(fallingTime > 1).

    Here's my updated Java code:



    public class fallingDistance
    {
    public static void main(String[] args)
    {
  7. Replies
    11
    Views
    1,958

    Java Program: Falling Distance Problem

    Here's the explanation of the problem:

    PROBLEM:


    OTHER STIPULATIONS (Made by Professor):


    And this is the sample Display Output we're suppose to have:
  8. Re: Java Program - Distance Traveled (Formatting and Decimal Place)

    #2, I want to know the other way of decimal fomatting. Still a bit confused by it.
  9. Re: Java Program - Distance Traveled (Formatting and Decimal Place)

    Thanks for the reply.

    I just typcasted the double into int (seems to work).

    But, can you give me a sample of how your approach will work, too?
  10. Re: Java Program - Distance Traveled (Formatting and Decimal Place)

    Okay, I was able to fix Issue #1.

    Just had to add some padding to "%d".

    Still can't figure out getting rid of the decimal places for the 80 and 120. I have "import java.text.DecimalFormat;" on...
  11. Java Program - Distance Traveled (Formatting and Decimal Place)

    Hi,

    I'm having trouble formatting my output and issues with the decimal places. Here's my code:


    import java.util.Scanner;
    import java.text.DecimalFormat; // Imports DecimalFormat class for...
  12. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    Yeah, the program works perfectly fine now.
  13. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    Oh no, I needed the question in program (but not in the place I initially had it). Sorry for not being clear from the start.
  14. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    It is, right? The program does ask for the service package first, then the number of hours used..Or is the program written in the wrong order in terms of execution of the statements?



    public...
  15. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    import java.util.Scanner;

    public class internetPackage
    {
    public static void main(String[] args)
    {
    String input;
    char servicePackage;
    int hoursUsed, regularHours, extraHours;...
  16. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    Nope, still gives me the same output, actually..
  17. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    I wanted to do that, but how would I write it?

    Would this work?

    If (servicePackage != 'A' && servicePackage != 'a' && servicePackage != 'B' && servicePackage != 'b' && servicePackage != 'C' &&...
  18. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    Oh, sorry. In my previous post, I actually mentioned that I took that "Invalid input. Hours cannot be negative." statement from it's original position and placed it as an ELSE statement for each...
  19. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    Whoops, my bad. It's under "Default." Towards the end of the program.

    For Switch Statements, "Default" acts like an "Else" incase the conditions being tested are all false, right?



    ...
  20. Replies
    18
    Views
    1,355

    Re: Help with Java Program!

    Okay, I was able to resolve the "Invalid input. Hours cannot be negative" by placing if (hoursUsed < 0) System.out.println("Invalid input. Hours cannot be negative."); into each switch.

    I'm still...
  21. Replies
    18
    Views
    1,355

    Help with Java Program!

    Hi everyone, first time entry. I have a problem with my java program output. It looks like the program logic is correct, but there are still some line of statements that are executed that I do not...
Results 1 to 21 of 24