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");