So I've decided I dont' really like programming. It's funny how this semester is playing out...I was so excited about taking my first Information Technology Management class and I hate it. Even more interesting is the fact that I was dreading Business Statistics and I'm finding out how much I like it. Just goes to show you that we don't always know what we are going to enjoy. Here is a sample of an awful program that I had to spend an hour with the tutor to figure out:
package firstproject;
import java.util.Scanner;
public class BinaryNumber
{
public static void main(String[]args)
{
Scanner keyboard = new Scanner(System.in);
int b0, b1, b2, b3;
String input = keyboard.next();
b0 = Integer.parseInt(input.substring(0,1));
b1= Integer.parseInt(input.substring(1,2));
b2= Integer.parseInt(input.substring(2,3));
b3= Integer.parseInt(input.substring(3));
int output = (8*b0) + (4*b1) + (2*b2) + (1*b3);
System.out.println("The answer is " + output);
}
}
7 years ago
No comments:
Post a Comment