package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC; // temperature in Celsius double average; // arithmetic average String output; // line of output to print out //Task #2 declare a variable to hold the user’s temperature //Task #2 prompt user to input score1 //Task #2 read score1 //Task #2 prompt user to input score2 //Task #2 read score2 // Find an arithmetic average average = score1 + score2 / NUMBER; output = score1 + " and " + score2 + " have an average of " + average; System.out.println(output); // Convert Fahrenheit temperatures to Celsius fToC = 5/9 * (BOILING_IN_F - 32); output = BOILING_IN_F + " in Fahrenheit is " + fToC + " in Celsius."; System.out.println(output); //Task #2 prompt user to input another temperature //Task #2 read the user’s temperature in Fahrenheit //Task #2 convert the user’s temperature to Celsius //Task #2 print the user’s temperature in Celsius System.out.println("Goodbye"); // to show that the program is ended } }
If you have any doubts, please give me comment...
Task1:
public class NumericTypes{
public static void main(String[] args) {
int score1 = 95;
int score2 = 100;
int numberOfScores = 2;
double average = (double)(score1+score2)/numberOfScores;
System.out.println(score1 + " and " + score2 + " have an average of " + average);
double F = 212;
double C = (5/9.0)*(F-32);
System.out.println(F + " in Fahrenheit is " + C + " in Celsius.");
}
}
Task 2:
import java.util.Scanner;
/**
* This program demonstrates how numeric types and operators behave in Java Do
* Task #1 before adding Task#2 where indicated.
*/
public class NumericTypesOriginal {
public static void main(String[] args) {
// TASK #2 Create a Scanner object here
Scanner in = new Scanner(System.in);
// identifier declarations
final int NUMBER = 2; // number of scores
int score1 = 100; // first test score
int score2 = 95; // second test score
final int BOILING_IN_F = 212; // boiling temperature
double fToC; // temperature in Celsius
double average; // arithmetic average
String output; // line of output to print out
// Task #2 declare a variable to hold the user’s temperature
int temp;
// Task #2 prompt user to input score1
System.out.print("Enter score1: ");
// Task #2 read score1
score1 = in.nextInt();
// Task #2 prompt user to input score2
System.out.print("Enter score2: ");
// Task #2 read score2
score2 = in.nextInt();
// Find an arithmetic average
average = (double)(score1 + score2) / NUMBER;
output = score1 + " and " + score2 + " have an average of " + average;
System.out.println(output);
// Convert Fahrenheit temperatures to Celsius
fToC = (5 / 9.0) * (BOILING_IN_F - 32);
output = BOILING_IN_F + " in Fahrenheit is " + fToC + " in Celsius.";
System.out.println(output);
// Task #2 prompt user to input another temperature
System.out.print("Enter temperature in Celsius: ");
// Task #2 read the user’s temperature in Fahrenheit
temp = in.nextInt();
// Task #2 convert the user’s temperature to Celsius
fToC = (5 / 9.0) * (temp - 32);
// Task #2 print the user’s temperature in Celsius
output = temp + " in Fahrenheit is " + fToC + " in Celsius.";
System.out.println(output);
System.out.println("Goodbye"); // to show that the program is ended
}
}
Task 3:
import java.util.Scanner;
public class SphereVolume{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Finding the volume of sphere");
System.out.print("Enter diameter: ");
double diameter = in.nextDouble();
double radius = diameter/2;
double V = (4/3.0)*Math.PI*Math.pow(radius, 3);
System.out.println("Volume of sphere with diameter "+diameter+" is: "+V);
}
}
package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task...
In Java. I am getting confused with this assignment, my confusion starts where I stopped. Create a package named temperature and create a program that has a while loop. • Inside the while loop, your program will prompt the user for temperature in Centigrade. • If the Centigrade value read in is <= -100, the loop will exit. • Otherwise, your program will compute the Fahrenheit equivalent temperature. • Inside the while loop, your program will print out the Centigrade...
in Java, temperature problem Create a package named temperature and create a program that has a while loop. • • Inside the while loop, your program will prompt the user for temperature in Centigrade. If the Centigrade value read in is <= -100. the loop will exit. Otherwise, your program will compute the Fahrenheit equivalent temperature. Inside the while loop, your program will print out the Centigrade and Fahrenheit temperatures. Keep a count of the valid user inputs and a...
Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...
Write a Java program that: 1. Decide on a list of n favorites (songs, bands, movies, video games, etc.) (between 5 and 10 favorites is fine). 2. Write a program that lists the n favorites but with a small twist. 3. Read in a file of n favorites (sample file in the Resources/Sample File area)...Please make your own. 4. Print a list of all n favorites to the user (so they know what is coming) 5. Ask if the user...
In this Final program you are going to use several concepts you learned in CSC 101 class, especially operations on or using FILES , LOOPS and FUNCTIONS. You need to implement C++ code that will read data from a file and process it as outlined below and write the processed data to an output file. You can refer to the file input.txt for how the data is made available to you and output.txt for how to write out the processed...
Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...
using Java program please copy and paste the code don't screenshot it import java.util.Scanner; import java.io.File; public class { public static void main(String[] args) { // Create a new Scanner object to obtain // input from System.in // --> TODO // Ask user for a word to search for. Print // out a prompt // --> TODO // Use the Scanner object you created above to // take a word of input from the user. // --> TODO // ***...
What to submit: your answers to exercises 2. Write a Java program to perform the following tasks: The program should ask the user for the name of an input file and the name of an output file. It should then open the input file as a text file (if the input file does not exist it should throw an exception) and read the contents line by line. It should also open the output file as a text file and write...
Description: This Java program will read in data from a file students.txt that keeps records of some students. Each line in students.txt contains information about one student, including his/her firstname, lastname, gender, major, enrollmentyear and whether he/she is a full-time or part-time student in the following format. FIRSTNAME LASTNAME GENDER MAJORENROLLMENTYEAR FULL/PART The above six fields are separated by a tab key. A user can input a keyword indicating what group of students he is searching for. For example, if...
Could you guys write an efficient java program to implement BST. Your java program should read words and its corresponding French and store it in a BST. Then read every English word and print its corresponding French by searching in BST. Assume your java program is in xxxxx5.java file (5th java project), where xxxxx is the first 5 characters of your last name. To compile: javac xxxxx5.java To execute: java xxxxx5 < any data file name Your main method should...