Results 1 to 3 of 3
  1. #1
    Phyxed is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default Can someone check this over?

    So a piece of my project is this:

    One kilobyte = 1024 bytes. Write an interactive program that converts from bytes to KB. The program will prompt the user for the number of bytes to convert. The program will convert to kilobytes as a result with decimal places and also as a whole value with left over bytes in a separate variable. Also, the program will convert to bits (recall 8bits = 1byte). The program will show the KB result in two different ways (decimal and as a whole number) and also, it will show the equivalent of bits.

    *Im kind of confused on the instructions and ive been sick so I have not been able to ask the teacher but this is what I came up with

    Thanks again guys and gals!



    * @(#)Project4.java
    *
    * Project4 application
    *
    * @author
    * @version 1.00 2011/3/27
    */
    import java.util.Scanner;
    public class Project4 {

    public static void main(String[] args) {

    /** 1) We will declare 5 variables which will all carry double types but one int. double bits, bytes, kbDec, kbleft
    * and int kbWhole
    * 2) We will then make 1 user inputs to get the amount of bytes the user wants converted.
    * 3) Once we are able to obtain the information from the user then we will calculate the decimal of the
    * inputed value into kilobytes, the whole number into kilobytes, any left over bytes, and also the the bytes converted to bits.
    * 4) Finally we have our output statement which will give the user the kilobytes in decimal form and whole form with left over bits.
    * I will also be converting the bytes into bits for the user as well.
    */

    //Title//
    System.out.println("Converting bytes to Kilobytes\n\n");

    //Declare//
    double bytes;
    double kbDec;
    double kbLeft;
    int kbWhole;
    double bits;

    Scanner keyboard = new Scanner(System.in);

    //Initialize//
    System.out.print("Please enter the number of bytes you want converted and hit enter = ");
    bytes = keyboard.nextDouble();

    //Calculate//
    kbDec = bytes/1024;
    kbWhole = (int)bytes/1024;
    kbLeft = (int)bytes%1024;
    bits = (double)bytes * 8;

    //Display//
    System.out.println("\n\n\nThe kilobytes converted in decimals is : " + kbDec + " kilobytes");
    System.out.println("\nThe kilobytes coverted to a whole number is : " + kbWhole + " kilobytes");
    System.out.println("\nThe left over bytes are : " + kbLeft + " bytes");
    System.out.println("\nThe bytes converted into bits are : " + bits + " bits");

  2. #2
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    So a piece of my project is this:

    One kilobyte = 1024 bytes. Write an interactive program that converts from bytes to KB. The program will prompt the user for the number of bytes to convert. The program will convert to kilobytes as a result with decimal places and also as a whole value with left over bytes in a separate variable. Also, the program will convert to bits (recall 8bits = 1byte). The program will show the KB result in two different ways (decimal and as a whole number) and also, it will show the equivalent of bits.

    *Im kind of confused on the instructions and ive been sick so I have not been able to ask the teacher but this is what I came up with

    Thanks again guys and gals!

    Your algo is okay in my opinion.Go through your algorithm.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    Please use code tags when posting code.

    Also, you never said if this works or not.

Similar Threads

  1. How check box can disabled
    By man4ish in forum AWT / Swing
    Replies: 3
    Last Post: 01-07-2010, 04:05 AM
  2. Don't know what to check for
    By Chasingxsuns in forum New To Java
    Replies: 8
    Last Post: 08-26-2009, 05:59 AM
  3. pls check it
    By aRTx in forum New To Java
    Replies: 0
    Last Post: 03-24-2009, 02:35 PM
  4. Check box tag
    By elizaabru in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-26-2008, 02:37 PM

Posting Permissions

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