Skip to content
Snippets Groups Projects
Commit 1711930b authored by Karkalašev, F. (Filip, Student B-TCS)'s avatar Karkalašev, F. (Filip, Student B-TCS)
Browse files

The exercises 8 & 9, making the Fahrenheit converter

parent b284f304
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ public class BookQuote extends HttpServlet { ...@@ -26,7 +26,7 @@ public class BookQuote extends HttpServlet {
PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter();
String docType = String docType =
"<!DOCTYPE HTML>\n"; "<!DOCTYPE HTML>\n";
String title = "Book Quote"; String title = "Fahrenheit converter";
out.println(docType + out.println(docType +
"<HTML>\n" + "<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE>" + "<HEAD><TITLE>" + title + "</TITLE>" +
...@@ -34,10 +34,10 @@ public class BookQuote extends HttpServlet { ...@@ -34,10 +34,10 @@ public class BookQuote extends HttpServlet {
"</HEAD>\n" + "</HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" + "<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>" + title + "</H1>\n" + "<H1>" + title + "</H1>\n" +
" <P>ISBN number: " + " <P>Temperature (in Fahrenheit): " +
request.getParameter("isbn") + "\n" + request.getParameter("isbn") + "\n" +
" <P>Price: " + " <P>Price: " +
Double.toString(quoter.getBookPrice(request.getParameter("isbn"))) + Double.toString(quoter.getBookPrice(Double.parseDouble(request.getParameter("isbn")))) +
"</BODY></HTML>"); "</BODY></HTML>");
} }
......
...@@ -17,9 +17,9 @@ public class Quoter { ...@@ -17,9 +17,9 @@ public class Quoter {
inputs.put("others", 0.0); inputs.put("others", 0.0);
} }
double getBookPrice(String isbn) { double getBookPrice(double isbn) {
return inputs.get(isbn); return ((isbn * 9) / 5) + 32;
} }
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
</head> </head>
<body> <body>
<h1>Web Book Quote Application</h1> <h1>Fahrenheit converter Application</h1>
<form ACTION="./bookQuote"> <form ACTION="./bookQuote">
<p>Enter ISBN number: <input TYPE="TEXT" NAME="isbn"></p> <p>Enter temperature (in Celcius): <input TYPE="TEXT" NAME="isbn"></p>
<input TYPE="SUBMIT"> <input TYPE="SUBMIT">
</form> </form>
......
...@@ -9,7 +9,7 @@ public class TestQuoter { ...@@ -9,7 +9,7 @@ public class TestQuoter {
@Test @Test
public void testBook1() throws Exception { public void testBook1() throws Exception {
Quoter quoter = new Quoter(); Quoter quoter = new Quoter();
double price = quoter.getBookPrice("1"); double price = quoter.getBookPrice(1);
Assertions.assertEquals(10.0, price, 0.0, "Price of book 1"); Assertions.assertEquals(10.0, price, 0.0, "Price of book 1");
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment