Skip to content

Commit d116377

Browse files
committed
Moved State and TestState to Problems module.
Began Chapter 05 Added 9 new files Modified 5 files Deleted 2 files.
1 parent 2c61019 commit d116377

File tree

16 files changed

+447
-206
lines changed

16 files changed

+447
-206
lines changed

.idea/misc.xml

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chapter05/Chapter05.iml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
12+

Chapter05/src/Coffee/Coffee.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package Coffee;
2+
/**
3+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
4+
* On: Jul at: 1:40 AM.
5+
* Project: Java Programming
6+
* Package: Coffee
7+
* File: ${FILE}
8+
*/
9+
public class Coffee
10+
{
11+
//TODO and fields, constructors, and methods;
12+
public static void main(String[] args)
13+
{
14+
//TODO add methods;
15+
}
16+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package CondoSales;
2+
import java.util.Scanner;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 10:22 AM.
6+
* Project: Java Programming
7+
* Package: CondoSales
8+
* File: CondoSales
9+
* Write an application for the Summerdale Condo Sales office; the program
10+
* determines the price of a condominium. Ask the user to choose 1 for park view,
11+
* 2 for golf course view, or 3 for lake view.
12+
* The output is the name of the chosen view as well as the price of the condo.
13+
* Park view condos are $150,000,
14+
* condos with golf course views are $170,000,
15+
* and condos with lake views are $210,000.
16+
* If the user enters an invalid code, set the price to 0. Save the file as CondoSales.java.
17+
*/
18+
public class CondoSales
19+
{
20+
public static final double PARKVIEW_PRICE = 150000.00;
21+
public static final double GOLFVIEW_PRICE = 170000.00;
22+
public static final double LAKEVIEW_PRICE = 210000.00;
23+
public static final String P = "You selected the Park View Condo with a sales price of ";
24+
public static final String G = "You selected the Golf View Condo with a sales price of ";
25+
public static final String L = "You selected the Lake View Condo with a sales price of ";
26+
public static final String I = "You selected an INVALID response, sales price is set to ";
27+
static int condoSelection;
28+
static double salesPrice;
29+
public static void main(String[] args)
30+
{
31+
Scanner enter = new Scanner(System.in);
32+
System.out.println("Please enter your condominium selection:\n1 - Park View\n2 - Golf " +
33+
"Course View\n3 - Lake View");
34+
condoSelection = enter.nextInt();
35+
boolean invalidResponse = (condoSelection > 3 || condoSelection < 0);
36+
if (condoSelection == 1)
37+
{
38+
salesPrice = PARKVIEW_PRICE;
39+
System.out.println(P + salesPrice);
40+
}
41+
else if (condoSelection == 2)
42+
{
43+
salesPrice = GOLFVIEW_PRICE;
44+
System.out.println(G + salesPrice);
45+
}
46+
else if (condoSelection == 3)
47+
{
48+
salesPrice = LAKEVIEW_PRICE;
49+
System.out.println(L + salesPrice);
50+
}
51+
else if (invalidResponse)
52+
{
53+
salesPrice = 0;
54+
System.out.println(I + salesPrice);
55+
}
56+
}
57+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package CondoSales;
2+
import java.util.Scanner;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 10:22 AM.
6+
* Project: Java Programming
7+
* Package: CondoSales
8+
* File: CondoSales
9+
* Add a prompt to the CondoSales application to ask the user to specify a
10+
* (1) garage or a (2) parking space, but only if the condo view selection
11+
* is valid. Add $5,000 to the price of any condo with a garage. If the parking
12+
* value is invalid, display an appropriate message and assume that the price
13+
* is for a condo with no garage. Save the file as CondoSales2.java.
14+
*/
15+
public class CondoSales2
16+
{
17+
public static final double PARKVIEW_PRICE = 150000.00;
18+
public static final double GOLFVIEW_PRICE = 170000.00;
19+
public static final double LAKEVIEW_PRICE = 210000.00;
20+
public static final double GARAGE = 5000.00;
21+
public static final String P = "You selected the Park View Condo with a sales price of ";
22+
public static final String G = "You selected the Golf View Condo with a sales price of ";
23+
public static final String L = "You selected the Lake View Condo with a sales price of ";
24+
public static final String I = "You selected an INVALID response, sales price is set to ";
25+
static int condoSelection;
26+
static double salesPrice;
27+
static int parking;
28+
static double condoAndParking;
29+
public static void main(String[] args)
30+
{
31+
Scanner enter = new Scanner(System.in);
32+
System.out.println("Please enter your condominium selection:\n1 - Park View\n2 - Golf " +
33+
"Course View\n3 - Lake View");
34+
condoSelection = enter.nextInt();
35+
boolean invalidResponse = (condoSelection > 3 || condoSelection < 0);
36+
if (condoSelection == 1)
37+
{
38+
salesPrice = PARKVIEW_PRICE;
39+
System.out.println(P + salesPrice);
40+
}
41+
else if (condoSelection == 2)
42+
{
43+
salesPrice = GOLFVIEW_PRICE;
44+
System.out.println(G + salesPrice);
45+
}
46+
else if (condoSelection == 3)
47+
{
48+
salesPrice = LAKEVIEW_PRICE;
49+
System.out.println(L + salesPrice);
50+
}
51+
else if (invalidResponse)
52+
{
53+
salesPrice = 0;
54+
System.out.println(I + salesPrice);
55+
}
56+
if (invalidResponse != true)
57+
{
58+
System.out.println("Please select a parking space: \n1 - Garage\n2 - Parking Space: ");
59+
}
60+
parking = enter.nextInt();
61+
boolean invalidParking = (parking > 2 || parking < 0);
62+
if (parking == 1)
63+
{
64+
salesPrice = salesPrice + GARAGE;
65+
System.out.println("The price of condo with garage is " + salesPrice);
66+
}
67+
else if (parking == 2)
68+
{
69+
salesPrice = salesPrice;
70+
System.out.println("The price of condo with parking space is " + salesPrice);
71+
}
72+
else if (invalidParking == true)
73+
{
74+
System.out.println("You have selected an INVALID response.");
75+
System.out.println("The price of condo with no garage is " + salesPrice);
76+
}
77+
}
78+
}

Chapter05/src/Even_Odd/EvenOdd.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package Even_Odd;
2+
import java.util.Scanner;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 7:42 AM.
6+
* Project: Java Programming
7+
* Package: Even_Odd
8+
* File: EvenOdd
9+
* Write an application that asks a user to enter an integer. Display a
10+
* statement that indicates whether the integer is even or odd. Save the
11+
* file as EvenOdd.java.
12+
*/
13+
public class EvenOdd
14+
{
15+
public static void main(String[] args)
16+
{
17+
int selection;
18+
Scanner enter = new Scanner(System.in);
19+
System.out.println("Please enter any number: ");
20+
selection = enter.nextInt();
21+
if (selection % 2 == 0)
22+
{
23+
System.out.println("Your have selected an even number");
24+
}
25+
else
26+
{
27+
System.out.println("Your have selected an odd number");
28+
}
29+
}
30+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package Scholarship;
2+
import java.util.Scanner;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 10:25 PM.
6+
* Project: Java Programming
7+
* Package: Scholarship
8+
* File: Scholarship
9+
* The Williamsburg Women’s Club offers scholarships to local high school
10+
* students who meet any of several criteria. Write an application that prompts
11+
* the user for a student’s numeric high school grade point average (for example,
12+
* 3.2), the student’s number of extracurricular activities, and the student’s
13+
* number of service activities.
14+
* <p/>
15+
* Display the message “Scholarship candidate” if
16+
* the student has any of the following:
17+
* 1. A grade point average of 3.8 or above and at least one extracurricular
18+
* activity and one service activity.
19+
* <p/>
20+
* 2. A grade point average below 3.8 but at least 3.4 and a total of at least
21+
* three extracurricular and service activities.
22+
* <p/>
23+
* 3. A grade point average below 3.4 but at least 3.0 and at least two
24+
* extracurricular activities and three service activities.
25+
* If the student does not meet any of the qualification criteria, display
26+
* “Not a candidate.” Save the file as Scholarship.java.
27+
*/
28+
public class Scholarship
29+
{
30+
public static double gradePointAverage;
31+
public static int activityExtra;
32+
public static int activityService;
33+
public static String scholarship = "Scholarship Candidate";
34+
public static String noScholarship = "Not A Candidate";
35+
public static void main(String[] args)
36+
{
37+
Scanner enter = new Scanner(System.in);
38+
System.out.println("Please enter your grade point average: ");
39+
gradePointAverage = enter.nextDouble();
40+
System.out.println("Enter the number of extra curriculum activities: ");
41+
activityExtra = enter.nextInt();
42+
System.out.println("Enter the number of service activities: ");
43+
activityService = enter.nextInt();
44+
boolean firstScholarship = (gradePointAverage >= 3.8 && activityExtra > 0 && activityService > 0);
45+
boolean secondScholarship = (gradePointAverage < 3.8 && gradePointAverage > 3.3 && (activityExtra > 2 && activityService > 2));
46+
boolean thirdScholarship = ((gradePointAverage < 3.4 && gradePointAverage > 2.9) && (activityExtra >= 2 && activityService >= 3));
47+
if (firstScholarship == true)
48+
{
49+
System.out.println(scholarship);
50+
}
51+
else if (secondScholarship == true)
52+
{
53+
System.out.println(scholarship);
54+
}
55+
else if (thirdScholarship == true)
56+
{
57+
System.out.println(scholarship);
58+
}
59+
else
60+
{
61+
System.out.println(noScholarship);
62+
}
63+
}
64+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package Scholarship;
2+
import java.util.Scanner;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 10:25 PM.
6+
* Project: Java Programming
7+
* Package: Scholarship
8+
* File: Scholarship
9+
* Modify the Scholarship application so that if a user enters a
10+
* grade point average under 0 or over 4.0, or a negative value
11+
* for either of the activities, an error message appears.
12+
* Save the file as Scholarship2.java.
13+
*/
14+
public class Scholarship2
15+
{
16+
public static double gradePointAverage;
17+
public static int activityExtra;
18+
public static int activityService;
19+
public static String scholarship = "Scholarship Candidate";
20+
public static String noScholarship = "Not A Candidate";
21+
public static void main(String[] args)
22+
{
23+
Scanner enter = new Scanner(System.in);
24+
System.out.println("Please enter your grade point average: ");
25+
gradePointAverage = enter.nextDouble();
26+
System.out.println("Enter the number of extra curriculum activities: ");
27+
activityExtra = enter.nextInt();
28+
System.out.println("Enter the number of service activities: ");
29+
activityService = enter.nextInt();
30+
boolean firstScholarship = (gradePointAverage >= 3.8 && activityExtra > 0 && activityService > 0);
31+
boolean secondScholarship = (gradePointAverage < 3.8 && gradePointAverage > 3.3 && (activityExtra > 2 && activityService > 2));
32+
boolean thirdScholarship = ((gradePointAverage < 3.4 && gradePointAverage > 2.9) && (activityExtra >= 2 && activityService >= 3));
33+
if (gradePointAverage > 4.0 || gradePointAverage < 0)
34+
{
35+
System.out.println("Grade Point Average is not in valid range.");
36+
}
37+
if (activityExtra < 0)
38+
{
39+
System.out.println("Extra Curricular activities is not valid.");
40+
}
41+
if (activityService < 0)
42+
{
43+
System.out.println("Service activities is not valid.");
44+
}
45+
if (firstScholarship)
46+
{
47+
System.out.println(scholarship);
48+
}
49+
else if (secondScholarship)
50+
{
51+
System.out.println(scholarship);
52+
}
53+
else if (thirdScholarship)
54+
{
55+
System.out.println(scholarship);
56+
}
57+
else
58+
{
59+
System.out.println(noScholarship);
60+
}
61+
}
62+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package Temperature;
2+
import java.util.Scanner;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 9:00 AM.
6+
* Project: Java Programming
7+
* Package: PACKAGE_NAME
8+
* File: Temperature.Temperature
9+
* Write an application that prompts the user for the day’s high and low
10+
* temperatures. If the high is greater than or equal to 90 degrees,
11+
* display the message, “Heat warning.” If the low is less than 32 degrees,
12+
* display the message “Freeze warning.” If the difference between the high
13+
* and low temperatures is more than 40 degrees, display the message, “Large
14+
* temperature swing.” Save the file as Temperatures.java.
15+
*/
16+
public class Temperature
17+
{
18+
public static int highTemp;
19+
public static int lowTemp;
20+
public static void main(String[] args)
21+
{
22+
Scanner enter = new Scanner(System.in);
23+
System.out.println("Please enter high temp of the day");
24+
highTemp = enter.nextInt();
25+
System.out.println("Please enter low temp of the day");
26+
lowTemp = enter.nextInt();
27+
int tempDiff = (highTemp - lowTemp);
28+
if (highTemp >= 90)
29+
{
30+
System.out.println("Heat Warning");
31+
}
32+
else if (lowTemp < 32)
33+
{
34+
System.out.println("Freeze Warning");
35+
}
36+
else if (tempDiff > 40)
37+
{
38+
System.out.println("Temperature.Temperature Swing");
39+
}
40+
else
41+
{
42+
System.out.println("No significant temperature changes.");
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)