Objectives 1 demonstrate the ability to write compile and ru

Objectives:

(1) demonstrate the ability to write, compile, and run a simple Java program

(2) demonstrate the ability to use iteration to convert a number from base b to base a.

(4) demonstrate the equivalency of the input and the converted number.

Instructions:

A. Write, compile, and run a Java program that: (1) uses a single line comment to

document your source code with your name and section number. This should be the

very first line of your program, (2) prints your name and section number as the first line

of your output, (3) prompts the user to enter a number, its base(b), and base to be

converted to(a), (4) reads these inputs from the keyboard and stores the number in a

double \"num\", base b in int \"b\", base a in int \"a\". (5) uses iteration to calculate the

conversion of numb, to numa (6) uses iteration to calculate the conversion of numbto

numa (7) prints the inputs num, b, and a the values of the conversions in appropriately

formatted and informative manner.

The real challenge of this lab exercise is to minimize the lines of code necessary to

solve the problem. DO NOT USE RECURSION!!

Solution

ans 1.) class myname

{

public static void main(String [] 1)

{

string n;

double a;

scanner oScanner=new ScannerSystem.in);

system.out.print(\"Name\");

n=oScanner.nextLine();

system.out.print(\"section\");

a=oScanner.nextLine();

system.out.print(\"Your name is\" +n+\"\ Your section is \"+a);

}

}

ans 2.)

public static void main(String args[]){

        Scanner input = new Scanner(System.in);

        System.out.println();

        System.out.println(\"Enter a number: \");

        double num = input.nextDouble();

        String num1 = Double.toString(num);

        System.out.println();

        System.out.println(\"Enter base \'a\': \");

        int a = input.nextInt();

        System.out.println();

        System.out.println(\"Enter base \'b\': \");

        int b = input.nextInt();

        System.out.println();

    }

    public double base10_to_2(double in){

        Scanner in = new Scanner(System.in);

        double a, r , q, c;

        while ( q > 0 )

            q = a/2;

         

        r = a%2;

         

        int [] r1 = new int [c + 1];   

         

    }

Objectives: (1) demonstrate the ability to write, compile, and run a simple Java program (2) demonstrate the ability to use iteration to convert a number from b
Objectives: (1) demonstrate the ability to write, compile, and run a simple Java program (2) demonstrate the ability to use iteration to convert a number from b

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site