Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 30 Weeks Ago, 4 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
INTRODUCTION: Java is the second of four languages you will be learning. Java is an object-oriented programming language used widely in business and industry.
Part 2 :
1. Modify the program to read user input for carYears
2. Write multiple if statements.
If carYear is 1969 or earlier, print "Probably has few safety features."
If 1970 or higher, print "Probably has seat belts."
If 1990 or higher, print "Probably has anti-lock brakes."
If 2000 or higher, print "Probably has air bags."
3. End each “phrase” with period and move the cursor to a newline.
Ex: carYear = 1995 prints:
Probably has seat belts.
Probably has anti-lock brakes.
import java.util.Scanner;
public class CarFeatures {
public static void main (String [] args) {
int carYear = 0;
carYear = 1940;
/* Your solution goes here */
return;
}
}
Part 3 :
import java.util.Scanner;
public class Salary {
public static void main(String [] args) {
Scanner scnr = new Scanner(System.in);
int hourlyWage = 0;
int weeklyHours = 0;
int weeklySalary = 0;
int overtimeHours = 0;
final int WEEKLY_LIMIT = 40;
System.out.println("Enter hourly wage: ");
hourlyWage = scnr.nextInt();
// FIXME: Get user input value for weeklyHours
weeklyHours = 40;
if (weeklyHours <= WEEKLY_LIMIT) {
weeklySalary = weeklyHours * hourlyWage;
}
else {
overtimeHours = weeklyHours - WEEKLY_LIMIT;
weeklySalary = (int)((hourlyWage * WEEKLY_LIMIT) +
(hourlyWage * overtimeHours * 1.5));
}
System.out.print("Weekly salary is: " + weeklySalary);
return;
}
-----------