Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Help. Please.

  1. #1
    New to the CF scene
    Join Date
    Nov 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help. Please.

    I'm new to coding and I'm struggling with two assignments. I wasn't able to find information in the textbook and these are due in two days so I'm kinda dying c:

    these are the assignments:

    BinaryConverter
    Give the user the option to convert a number from binary to decimal, or vice versa.
    If they want to convert from binary to decimal, assume that itís an 8-bit number.
    (Optional challenge: allow the user to enter any number up to 32-bit, and convert to decimal regardless of how many bits it is. Do not ask the user how many bits it is.)
    If they want to convert from decimal to binary, assume that itís 8-bit.

    Dice
    Create a class called Die. It has 1 method, roll( ), which receives 1 parameter. This parameter is the number of sides the die has. In the method, roll the die, and return (***but donít display***) the result. Next, create a client, DieClient, that asks how many sides the die has, then rolls the die once (by calling the method) and displays the result.
    Create a second client called BoxCars. It rolls a pair of 6-sided dice 1000 times (do this by using, but not changing at all, the Die class). Display all the rolls, and count how many times ďboxcarsĒ (a pair of 6ís) occurs.

    can somebody help me?

  2. #2
    Super Moderator vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,278
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Obviously you didn't read our forum rules, specifically this one:

    1.5) No homework assignments - Do not post your entire homework assignment and request that other members do it for you. This is considered cheating, and your thread may even be used by your school to prove your guilt. Now, you may ask for advice or help on a specific aspect of your assignment that you're having trouble with. Use common sense as far as what's acceptable in terms of soliciting help with homework assignments.
    Show some effort on your homework assignment, then we'll be happy to help you.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  3. #3
    New to the CF scene
    Join Date
    Nov 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ah, sorry!! I didn't see it, I'll post what I have so far!

  4. #4
    New to the CF scene
    Join Date
    Nov 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm sorry for not reading the forum rules thoroughly, that was really stupid of me

    for the dice project this is what I have, I was able to make a dice class and client but I'm not sue how to do the boxcars segment:
    this is the dice class:
    Code:
    import java.util.Random;
    public class Dice
    {
        private int roll;
        private int side;
        public int roll(int sides)
        {
            Random scramble = new Random();
            roll = scramble.nextInt(side);
            return roll;
        }
        public int sides()
        {
            return side;
        }
    }
    this is the dice client:
    Code:
    import java.util.Scanner;
    public class DieClient
    {
        public static void main()
        {
            Dice myDice = new Dice();
            Scanner myScanner = new Scanner (System.in);
            System.out.println("how many sides does ur dice have ");
            int a;
            a = myScanner.nextInt();
            System.out.println("You rolled a " + myDice.roll(a));
        }
    }
    and I'm not sure how to do binary converter at all
    Last edited by vinyl-junkie; 11-03-2016 at 02:41 PM. Reason: added code tags

  5. #5
    New Coder
    Join Date
    Sep 2016
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by sadbeginner View Post
    i'm sorry for not reading the forum rules thoroughly, that was really stupid of me

    for the dice project this is what I have, I was able to make a dice class and client but I'm not sue how to do the boxcars segment:
    this is the dice class:
    Code:
    import java.util.Random;
    public class Dice
    {
        private int roll;
        private int side;
        public int roll(int sides)
        {
            Random scramble = new Random();
            roll = scramble.nextInt(side);
            return roll;
        }
        public int sides()
        {
            return side;
        }
    }
    this is the dice client:
    Code:
    import java.util.Scanner;
    public class DieClient
    {
        public static void main()
        {
            Dice myDice = new Dice();
            Scanner myScanner = new Scanner (System.in);
            System.out.println("how many sides does ur dice have ");
            int a;
            a = myScanner.nextInt();
            System.out.println("You rolled a " + myDice.roll(a));
        }
    }
    and I'm not sure how to do binary converter at all
    I can't help you but I can say that you didn't include the Dice class.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •