this the second question for the assignment that was not in the book. HouseSigns
ID: 3683092 • Letter: T
Question
this the second question for the assignment that was not in the book.
HouseSigns.java
Mark Daniels is a carpenter who creates personzalized house signs. He wants an application to compute the price of any sign a customer orders, based on the following factors:
The minimum charge for all signs is $30
If the sign is made of oak, add $15. No charge is added for pine
The first six letters or numbers are included in the minimum charge; there is a $3 charge for each addidtional character
Black or white characters are included in the minimum charge, there is an additional $12 charge for goal-leaf lettering
using the inforamtion above wrtie a program that does the following.
Accepts data for an order number, customer naem, wood type, number of characters, and color of characters. Display all entered data and the final price for the sign
Explanation / Answer
package com.chegg.java;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class HouseSigns
{
static int orderNumber;
static String customerName;
static String woodType;
static int no_of_characters = 6;
static String color_of_characters;
public static int calculatePrice(String woodType,int no_of_chars,String color_of_chars) {
int min_charge = 30;
int price = min_charge;
if(woodType.equalsIgnoreCase("oak")) {
price = price + 15;
}
if(no_of_chars > 6) {
price = price + (no_of_chars-6)*3;
}
if(color_of_chars.equalsIgnoreCase("goal-leaf lettering")) {
price = price + 12;
}
return price;
}
public static void main(String[] args) throws IOException
{
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Order Number :");
orderNumber = Integer.parseInt(bufferRead.readLine());
System.out.println("Enter Customer Name :");
customerName = bufferRead.readLine();
System.out.println("Enter woodType (only oak or pine ): ");
woodType = bufferRead.readLine();
System.out.println("Enter noOfCharacters : ");
no_of_characters = Integer.parseInt(bufferRead.readLine());
System.out.println("Enter colorOfCharacters : ");
color_of_characters = bufferRead.readLine();
bufferRead.close();
System.out.println("orderNumber : " +orderNumber+" "+
"customerName : "+customerName +" "+"woodType : "+woodType+" "+
"no of characters : "+no_of_characters +" "+"color of characters(Only Black/White/goal-leaf lettering) : "+color_of_characters+" ");
int price = calculatePrice(woodType, no_of_characters, color_of_characters);
System.out.println("Final Price for House Sign is : "+ price);
}
}
Sample Output :
orderNumber : 555
customerName : Sunilkumar Kota
woodType : Oak
no of characters : 8
color of characters(Only Black/White/goal-leaf lettering) : goal-leaf lettering
Final Price for House Sign is : 63
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.