Question: help



Share on Google+Share on Google+

1 Answer(s)      5 years and 5 months ago
Posted in : JavaScript Questions

Soni Electric Company celebrates their 10th anniversary by having a special promotion for 2 weeks. Each customer who purchases any electrical equipments or components in a single receipt will get special discount according to the total amount they purchase. The discount rate will be given according to the indicator below:total purchase<500,discount rate=0%;total purchase>=500but<700,discount rate=5%;total purchase>=700but<1000,discount rate=7%;total purchase>1000,discount rate=10%

Total amount of payment is computed by this formula: Total Payment = T?? T*(D/100) where T is the total purchase in RM and D is the discount rate in percent according the total amount purchased. Based on the above scenario, write a complete Java program. Your program should have two (2) classes namely, Purchase and PurchaseDemo class . Purchase class has three (3) methods. a. input() method reads a customer name and total purchased. b. calculateTotalPayment() method calculates the total payment c. display() method displays the name of customer, total purchased, discount rate and total payment.

Meanwhile, PurchaseDemo class only have main() method. main() method creates an object from Purchase class. It calls input() method to read a customer name and total purchased , then calculateTotalPayment() method calculates the total payment and display() method displays the name of customer, total purchased, discount rate and total payment.

View Answers

December 2, 2011 at 5:29 PM

import java.util.*;
class  Purchase
String name;
double purchase;
double drate;

public void input(){
Scanner input=new Scanner(;
System.out.print("Enter Name: ");
System.out.print("Total Purchase: ");
public double calculateTotalPayment(){

double rate=drate/100;
double discount=rate*purchase;
double total=purchase-discount;
return total;
public void display(double totalPayment){
    System.out.println("Name: "+name);
    System.out.println("Purchase: "+purchase);
    System.out.println("Discount Rate: "+drate+"%");
    System.out.println("Total Payment: "+totalPayment);

class PurchaseDemo{

    public static void main(String[] args) 
        Purchase p=new Purchase();
        double payment=p.calculateTotalPayment();


Related Tutorials/Questions & Answers:
help   how i can send a pitcture on url in java
help  pls help me to get the code of a java program a program to perform different shapes in a menu using javaapplet
help  i need help with this code. write a java code for a method named addSevenToKthElement that takes an integer array, and an integer k as its arguments and returns the kth element plus 7. any help would be greatly
HELP  I need this code to open in a new web browser. but no matter what i do it wont please help?? Directive 055 Storage Requirements for the Upstream Petroleum Industry
Help...  Write a class that displays your first name vertically down the screen ?? where each letter uses up to 5 rows by 5 columns of a character input by you with a blank line between each letter
Help   i have a html file.. i have take input and store in database .. Tell me the steps to perform.. i have xampp it includes mysql,tomacat,apache. and how display the data from datbase .. please explain
Help!  thanks for ur code, I'd like to ask a question: after press "c" or "C", timer starts and after every delay ms, it'll print "This line is printed only once." or just print once. I'm writting a timer but it seems to perform
Help  Hi; Can anyone help me to solve this errors. I use J2ME(wirlesee Toolkit 2.5.2. for CLDC Project "SlideImageMIDlet" loaded Project settings saved Building "SlideImageMIDlet" C:\Documents and Settings\???? ?????\j2mewtk
to the user) please tell me how could i design that. Please help me asap Thanks a lot
based on the percentage of cheating. please help me
help!!!!!!!!!!!!!!!!!!  import java.awt.; import java.sql.*; import javax.swing.*; import java.awt.event.* public class NewJFrame extends javax.swing.JFrame { JTextField1
Regular Expression Help Help HELP!!!!
Regular Expression Help Help HELP!!!!  HI all I am very new to java... could help me to give a solution of how to retrieve the name and email add... the quotes ""07001", "MR Harish Ram","M.RHarish @"" Help is greatly
Help me
Help me  Hi, LWUIT is working in eclipse j2me for Symbian OS
help me
help me  HI. Please help me for doing project. i want to send control from one jsp page to 2 jsp pages... is it possible? if possible how to do
Help Me
Help Me  What is the source code for Sample example for Mortgage Calculator in J2ME language for developing Symbian
help me
help me  how to print from a-z, A-Z with exact order using for loop? Thanks for all concern
help me
help me  i have done as u directed but nothing happens gud to me..... . i am using netbeans is that matter at all help me and take me out from trouble where to store jfree api to use it for j2ee based project
help me
help me  MY GLASSFISH SERVER NOT START PROPERLY help me warning shows DPL5404:Specification-Version for the optional package [ GNUJAXP ] in the jarfile [ C:\Program Files\Java\jdk1.7.0_02\jre\lib\ext\gnujaxp.jar
Timeseries help
Timeseries help  hey....... can u plz help me in time series code. Can u provide a tie series code that is using the method Time series. I have seen... of Barchart???? plz help
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java


Advertisement null