Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write Java assignment statement(s) that perform the following operations with th

ID: 673525 • Letter: W

Question

Write Java assignment statement(s) that perform the following operations with the int variables a, b and c. Use the appropriate data type to write the correct Java syntax.

Add 8 to a and store the result in c

Assign the same value to a and to b and to c

Divide c by 1/4 and store the result in b

Multiply b times 22 and store in a

Subtract 5 from c and store the result in b

Find the remainder of a divided by c and store it in b

Divide 15 by 2.5 and store the result in b after you add 8

Store the byte x in a

Use Best Practice procedures which include comments to program the following:

      2.     Convert the following pseudocode to a Java program. You will need to declare the appropriate variables:

                    start main()

store 30 in the variable, milesGallon // mpg that this vehicle averages

store 12 in the variable, numGallons // number of gallons used for the trip

calculate the variable, totalMiles by multiplying the number of gallons used by mpg and store the result in totalMiles

display the content of totalMiles

                      end main()

Convert the following pseudocode to a Java program (code). Will need to declare the appropriate variables:

              start main

store 2.2 in the poundsPerKilo variable

store 600 in the variable, numPounds // weight of the machine

calculate the machine’s weight in kilos by dividing numPounds by poundsPerKilo, and store the result

       in totalKiloGrams

display the content of totalKiloGrams

                       end   main

      4.  Personal_Info

Create a Java program that displays the following heading on one line:

First Name               Last Name                    Address                Phone         Number             Major

======================================================================================

Display your information on the second line. Keep the address simple - just looking for a one line address such as a street address or building and/or apartment number. Add 2 more names with personal information – can be fictitious. You will need to use escape characters to format the output.  See p. 126 (p. 64 ver9).

5. StudentHoursWorked - A UD student is working on a job and is required to enter the amount of time he/she worked in minutes. Create a Java program that displays the time worked in hours and minutes. Please look at Listing 2.4 / 2.5 DisplayTime.java on p. 47 as an example of using the % operator. You will use the Scanner class for input. Create the pseudocode. We will do the flowchart in class.

Explanation / Answer

Answers:

1)

Given int a,b,c;
c=a+8; //Add 8 to a and store the result in c
a=8; //Assign the same value to a and to b and to c
b=8; //Assign the same value to a and to b and to c
c=8; //Assign the same value to a and to b and to c
b=c/4; //Divide c by 1/4 and store the result in b
a=b*22; //Multiply b times 22 and store in a
b=c-5; //Subtract 5 from c and store the result in b
b=a%c; //Find the remainder of a divided by c and store it in b
b=15/2.5+8; //Divide 15 by 2.5 and store the result in b after you add 8
byte x=(byte)a; //Store the byte x in a

2)

class Gallon
{
   public static void main(String args[])
   {
      
       int milesGallon=30;// mpg that this vehicle

averages
       int numGallons=12; // number of gallons used for

the trip
       int totalMiles;
       totalMiles=numGallons*milesGallon;
       System.out.println(totalMiles);
      
   }
}

3)

class KiloGrams
{
   public static void main(String args[])
   {
      
       double poundsPerKilo=2.2;
       int numPounds=600; //weight of the machine
       double totalKiloGrams;
       totalKiloGrams=numPounds*poundsPerKilo;
       System.out.println(totalKiloGrams);
      
   }
}

4)

class Personal
{
   public static void main(String args[])
   {
      
       System.out.print("First Name");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Last Name");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Address");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Phone Number");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Major");
       System.out.print(" ");
       System.out.print

("===========================================================

======");
       System.out.print(" ");
       System.out.print("Kalyan");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Eamani");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Mohan nagar");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("8096212156");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Yes");
       System.out.print(" ");
       System.out.print("Sujeeth");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Eamani");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Mohan nagar");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("0402404103");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Yes");
       System.out.print(" ");
       System.out.print("Vignesh");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Vicky");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("Mohan Nagar");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print("0402404105");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
       System.out.print(" ");
      
       System.out.print("No");
       System.out.print(" ");
   }
}

5)

import java.util.*;
class StudentHoursWorked
{
   public static void main(String args[])
   {
       Scanner keyboard = new Scanner(System.in);
       System.out.println("Enter number of minutes: ");
       double minute= keyboard.nextDouble();
  

       double Hours = Math.floor(minute /60);
       double Minutes = minute %60;
  
       System.out.println("Minutes in Hours and Minutes

is "+Hours+" Hours and "+Minutes+" Minutes ");
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote