Question

In: Computer Science

Lab Directions: Complete each of the programs here. Create a separate Netbeansproject for each program using...

Lab Directions:

Complete each of the programs here. Create a separate Netbeansproject for each program using the name I specified. Create a single java main class for each of the programs using the filename I specified.


Task 1: (5 points)

Project name: CtoFConverter
Main file name: TempConverter.java

A program that converts an inputted temperature in C and provides the equivalent temperature in F. Hint: Google is your friend! Given C, solve for F. Again, check for a valid input value and only respond with the F value if you got it, otherwise output an appropriate error msg to the user. Testing: 3 conditions: Bad Input, then test for the known freezing and boiling points.

EMBED SCREEN SHOT(S) OR COPY THE OUTPUT WINDOW OF NETBEANS HERE SHOWING YOUR PROGRAM TEST RUN(S):


Task 2: (5 points)
Project name: FuelCosts
Main file name: FuelCost.java

Write a program that asks the user to input

The number of gallons of gas currently in the tank
The fuel efficiency in miles per gallon

Then print how far the car can go with the gas in the tank. Again, check for valid input and exit with an error msg if you do not have it. Testing: here just use some reasonable values that you can inspect the calculations and determine they are correct.

EMBED SCREEN SHOT(S) OR COPY THE OUTPUT WINDOW OF NETBEANS HERE SHOWING YOUR PROGRAM TEST RUN(S):

Submitting your work:

Create a new compressed .zip archive folder. (Don’t give me any other type of archive, it will be returned to you ungraded!) called Lastname_Firstname_Lab_06.zip using your name.  

Place both of your Netbeans project folders in this archive. (Do not individually zip the projects!) Place this word doc file with your screen shots in the archive as well. (Don’t put this in the individual project folders, put it in the top level in the archive so I can access it easily.)

(When I open you archive I should see each of your project folders in it and this file.)

Submit the one Zip file (with both NetBeans projects and the Word document) for your grade.


Lab Directions:

Complete each of the programs here. Create a separate Netbeans project for each program using the name I specified. Create a single java main class for each of the programs using the filename I specified.

Task 1: (5 points)
Project name: CtoFConverter
Main file name: TempConverter.java
A program that converts an inputted temperature in C and provides the equivalent temperature in F. Hint: Google is your friend! Given C, solve for F. Again, check for a valid input value and only respond with the F value if you got it, otherwise output an appropriate error msg to the user. Testing: 3 conditions: Bad Input, then test for the known freezing and boiling points.

EMBED SCREEN SHOT(S) OR COPY THE OUTPUT WINDOW OF NETBEANS HERE SHOWING YOUR PROGRAM TEST RUN(S):

Task 2: (5 points)
Project name: FuelCosts
Main file name: FuelCost.java
Write a program that asks the user to input
• The number of gallons of gas currently in the tank
• The fuel efficiency in miles per gallon
Then print how far the car can go with the gas in the tank. Again, check for valid input and exit with an error msg if you do not have it. Testing: here just use some reasonable values that you can inspect the calculations and determine they are correct.

Solutions

Expert Solution

1. CODE IN JAVA:

TempConverter.java file:

import java.util.Scanner;

public class TempConverter {

   public static void main(String[] args) {
       // creating object to the Scanner class to take input from the user
       Scanner sc = new Scanner(System.in);
       // taking temperature in celcius as input from the user
       System.out.print("Enter temperature in celcius:");
       double celcius = sc.nextDouble();
       // converting celcius to fahrenheit
       double fahrenheit = ((celcius * 9) / 5) + 32;
       // displaying the temperature in Fahrenheit
       System.out.printf("Corresponding temperature in fahrenheit:%.2f\n", fahrenheit);

   }

}

OUTPUT:

2. CODE IN JAVA:

FuelCost.java file:

import java.util.Scanner;

public class FuelCost {

   public static void main(String[] args) {
       // creating object to the Scanner class to take input from the user
       Scanner sc = new Scanner(System.in);
       // taking input from the user
       System.out.print("Enter the number of gallons of gas currently in the tank:");
       double num = sc.nextDouble();
       System.out.print("Enter the fuel efficiency in miles per gallon:");
       double efficiency = sc.nextDouble();
       // calculating travel distance of the car
       double distance = num * efficiency;
       // displaying the travel distance
       System.out.println("The car can travel maximum " + distance + " miles");

   }

}

OUTPUT:


Related Solutions

Complete each of the programs here. Create a separate Netbeans project for each program using the...
Complete each of the programs here. Create a separate Netbeans project for each program using the name I specified. Create a single java main class for each of the programs using the filename I specified. Task 1: (5 points) Project name: CtoFConverter Main file name: TempConverter.java A program that converts an inputted temperature in C and provides the equivalent temperature in F. Hint: Google is your friend! Given C, solve for F. Again, check for a valid input value and...
C Programming Language: For this lab, you are going to create two programs. The first program...
C Programming Language: For this lab, you are going to create two programs. The first program (named AsciiToBinary) will read data from an ASCII file and save the data to a new file in a binary format. The second program (named BinaryToAscii) will read data from a binary file and save the data to a new file in ASCII format. Specifications: Both programs will obtain the filenames to be read and written from command line parameters. For example: - bash$...
Instructions Complete the lab using “for loop”. Do not write the code in multiple programs. All...
Instructions Complete the lab using “for loop”. Do not write the code in multiple programs. All the 3 methods should be written in 1 program. Write a java program calls the following methods: printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop. Multiples(): Takes an int (n) as parameter and prints first 10 multiples n in a single line using for loop. hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game that involves betting on the sum of two dice. The player will start out with some initial total amount of money. During each round, the player can bet some money that the sum of the two dice will be equal to a certain number. If the player wins the bet, that player adds the amount of the bet to his or her current total....
Write a  program in c++ using a map to create the following output. Here is the list...
Write a  program in c++ using a map to create the following output. Here is the list of students: 100: Tom Lee 101: Joe Jones 102: Kim Adams 103: Bob Thomas 104: Linda Lee Enter a student an ID to get a student's name: ID:  103 students[103] - Bob Thomas # of students: 5 Delete a student (Y or N)?  Y Enter ID of student to be deleted:  103 Here is the list of students after the delete: 100: Tom Lee 101: Joe Jones...
Create a program (or set of programs) which accomplish the following for each complex data type...
Create a program (or set of programs) which accomplish the following for each complex data type (list,tuple,set,frozenset, dictionary): create the item with at least 4 elements Append an element Remove an element Insert an element in the middle somewhere Append another array of the same data type Append another array of a different data type (for example, if you have a dictionary, append a set or tuples And do the following: Output the results after each step. Report and explain...
Create a program (or set of programs) which accomplish the following for each complex data type...
Create a program (or set of programs) which accomplish the following for each complex data type (list,tuple,set,frozenset, dictionary): create the item with at least 4 elements Append an element Remove an element Insert an element in the middle somewhere Append another array of the same data type Append another array of a different data type (for example, if you have a dictionary, append a set or tuples And do the following: Output the results after each step. Report and explain...
write C++ program using functions (separate function for each bottom) Write a program to find if...
write C++ program using functions (separate function for each bottom) Write a program to find if a number is large word for two given bottom base - bottom1 and bottom2. You can predict that a number, when converted to any given base shall not exceed 10 digits. . the program should ask from user to enter a number that it should ask to enter the base ranging from 2 to 16 after that it should check if the number is...
`DIRECTIONS: Write an answer to each question legible, using complete sentences and your own words as...
`DIRECTIONS: Write an answer to each question legible, using complete sentences and your own words as much as possible. 6.           What information is needed to directly determine the range of a projectile without using the equations of uniformly accelerated motion? 7.           At what point in its motion does an ideal projectile stop accelerating? 8.           Do two projectiles launched at complementary angles always yield the same range? Explain. 9.           When someone says that all measurement of motion is relative, what is...
Directions: Create a program that takes as input an employee's salary and a rating of the...
Directions: Create a program that takes as input an employee's salary and a rating of the employee's performance and then computes the appropriate raise for the employee based on that rating. The performance rating is entered into the program as a String. The three possible ratings are "Outstanding", "Acceptable", and "Needs Improvement". An employee who is rated as Outstanding will receive a 10.2% raise, one rated Acceptable will receive a 7% raise, and one rated as Needs Improvement will receive...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT