Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

For this assignment, you will be modifying the exercises from the previous assignment.

Change them to use a keyboard scanner instead of hard-coding values.

Use the nextLine() and parsing technique

We need to use the scanner
import java.util.Scanner;

Then created a keyboard reader

Scanner keyboard = new Scanner(System.in)

Write a Java program to convert temperature from Fahrenheit to Celsius.
public static void main(String[] args) {
double fahrenheit = 123.45;
double celcius = ((5 * (fahrenheit - 32.0)) / 9.0);

System.out.println("Exercise #1");
System.out.println(fahrenheit + "F is " + celcius + "C");
Output:
Exercise #1
Enter Fahrenheit: 123.45
123.45F is 50.80555555555556C
Exercise 2
Write a Java program that converts inches to meters
Use double variables inches and meters.
(One inch is 0.0254 meters)
public static void main(String[] Strings) {

Scanner input = new Scanner(System.in);

System.out.print("Input a value for inch: ");
double inch = input.nextDouble();
double meters = inch * 0.0254;
System.out.println("Exercise #2");
System.out.println(inch + " inch is " + meters + " meters");
Output:
Enter inches: 1000.0
1000.0 inches are 25.4 meters
Exercise 3
Concatenate first, middle, and last name
Create 3 Strings (firstName, middleInitial, and lastName)
Create 4th String variable named fullName and use the + operator to concatenate all parts of the name into one full name.
The user will input the data.
Enter your first name: Johhn
Enter your middle initial: J
Enter your last name: Jose

The full name is: John J. Jose
public static void main(String[] args) {
String fullName = "John J. Jose";
String lastName = fullName.substring(14);
System.out.println("Exercise #3");
System.out.println( "The full name is " + fullName);
Write a Java program to demonstrate the Java arithmetic operators
Name the integer variables x and y. That's okay to have single letter variables for this small demonstration.
Input x and y from the keyboard
Write the appropriate code to give this output:
public static void main(String args[]) {
int x = 11;
int y = 5;
System.out.println("Exercise #4");
System.out.println("11 + 5 = " + (x + y) );
System.out.println("11 - 5 = " + (x - y) );
System.out.println("5 - 11 = " + (y - x) );
System.out.println("11 * 5 = " + (x * y) );
System.out.println("11 / 5 = " + (x / y) );
System.out.println("11 % 5 = " + (x % y) );
}
Sample
Enter x: 12
Enter y: 6

12 + 6 = 18
12 - 6 = 6
6 - 12 = -6
12 * 6 = 72
12 / 6 = 2
12 % 6 = 0

Java, Programming

  • Category:- Java
  • Reference No.:- M92400051
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Java

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As