Help needed on homework assignment!!!

I am new to Java. Could anybody please help me figure out the problem in my code. I have to
The class A2 has to perform this operation:
It will prompt for user�s inputs, call the methods of the other two classes to convert the date and calculate the stock sale, and displays the outputs on the screen.
The class SellStocks has to perform this operation:
It will provide instance methods with parameters to calculate the value of the shares, the commission and the net proceeds of a stock.
The A2 class code is:
import jpb.*;
public class A2 {
  public static void main(String[] args) {
    SimpleIO.prompt("Enter today's date: ");
    String date = SimpleIO.readLine();
    SimpleIO.prompt("Enter stock price: ");
    String price = SimpleIO.readLine();
    SimpleIO.prompt("Enter number of shares: ");
    String number = SimpleIO.readLine();
    SimpleIO.prompt("Enter commission rate (as a percentage) : ");
    String rate = SimpleIO.readLine();
    double number1 = Convert.toDouble(number);
    double price1 = Convert.toDouble(price);
    double rate1 = Convert.toDouble(rate);
    SellStocks stock = new SellStocks();
    stock.sell(number1, price1, rate1);
    System.out.println();
    System.out.println("Today is: " + date);
    System.out.println("Value of shares: $" + price);
    System.out.println("Commission: $" + number);
    System.out.println("Net Proceeds: $" + rate);
}And the SellStocks class is:
public class SellStocks {
    private double value;
    private double commission;
    private double proceeds;
    public void sell (double num, double pri, double rat) {
     value = pri * num;
     commission = value * rat;
     proceeds = value - commission;
     pri = value;
     num = commission;
     rat = proceeds;
}I would really appreciate it if anybody could help me. Thanks a lot

Java is purely pass-by-value. The consequence of this is that when you change the value of a parameter inside a method, that change is not reflected in the caller.
If you need that method to modify three values and have all three changes seen by the caller then you can do it one of two ways. Either way, you need an object that encapsulate those three values.
In one solution, you pass a reference to that object to the method, and the method simply modifies that object's fields in place. (QUIZ: This may seem to be contradictory with the bolded statement above. (Does it?) It's not. Why?)
The other way is to have the method create that object and simply return a reference to it. In your case here, either one will work fine, but I'd lean toward the second one as a better division of responsibility.

Similar Messages

  • Help needed with homework.

    Hi,
    I need help with my homework. It is pretty critical, since I have to turn it in tommorow.
    Im having problems with my class Ordre, which looks like this:
    Ordre translations: Ordre=Orders
    -nummer:int nummer=number
    -opretDato:DkDate opretDato=makeDate
    +Ordre(nr:int)
    +Ordre(nr:int,year:int,month:int,dayOfMonth:int
    +getNummer():int
    +setOpretDato():void                                                                                                       
    +setOpretDato(y:int,m:int,d:int):void
    +getOpretDato():DkDate
    +toString():String
    Exercise question 1: Make the code for all the classes, without thinking about associating/komposition yet. Ordre(nr:int) and setOpretDato(), must set the date to 'current days date'.+
    Notice: DkDate is a class you dont currently have permission to use. Your opretDato must be of the type Date.+
    Ex. on how to give a date, the value current date: Date opretDato = new GregorianCalendar().getTime();
    Ex. on how to give a date, the value of a date: Date opretDato = new GregorianCalendar(year,month,dayOfMonth).getTime();
    Im having a hard time figuring out how to code this.
    But here is my code so far:
    import java.sql.Date;
    import java.util.GregorianCalendar;
    public class Ordre {
         private int nummer;
         private Date dato;// = (Date) new GregorianCalendar().getTime();
         public Ordre (int nummer){
              this.nummer=nummer;
         public Ordre (int nummer, int dayOfMonth, int month, int year){
              this.nummer=nummer;
         public int getNummer(){
              return nummer;
         public void setOpretDato(int dm,int m,int y){
              Date newDato = (Date) new GregorianCalendar(dm, m, y).getTime();
              dato=newDato;
         public Date getDato(){
              return dato;
         public Integer toString(int i){
              i=nummer;
              return i;
    }Any help (with or without shoots fired at my newbness) is grately appriciated.

    Date d = new Date(); suffices for current time... and make sure you use java.util.Date, not java.sql.Date.
    Anyway, what exactly is your problem? Let your constructor also assign this.dato with a new Date instance and you're done. If you have problems, please post the error message. People here aren't very good at mind-reading.

  • Help Needed For Algorithm Assignment????

    Hi there! Well I'm quite new to this, therfore I would greatly appreciated if some1 could help me with my assignment.
    Assignment:
    Make an applet that makes an object(red oval) move around the applet window by using only four buttons(Up, Right, Down, Left).
    I managed to do the button and the oval but both are not connected.
    Can some1 help me with the codes coz my assignment is due this week!!

    I don't uderstand wat u meant by "how you would change things to get the oval to move in each direction."
    I was given a piece of paper with the assignment written on it and also the picture of what the outcome of it....We were supposed to write our own codes.
    Here are what I've already done:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class Game extends Applet implements ActionListener{
         Button up1 = new Button("Up");
         Button down1 = new Button("Down");
         Button right1 = new Button("Right");
         Button left1 = new Button("Left");
         public void init() {
              Panel p = new Panel(new GridLayout(3, 3));
              p.setBackground(Color.white);
              p.add(new Label(""));
              p.add(up1);
              up1.addActionListener(this);
              p.add(new Label(""));
              p.add(left1);
              left1.addActionListener(this);
              p.add(new Label(""));
              p.add(right1);
              right1.addActionListener(this);
              p.add(new Label(""));
              p.add(down1);
              down1.addActionListener(this);
              add(p);
         public void actionPerformed(ActionEvent event) {
                   repaint();
         public void paint(Graphics g) {
              Font font = new Font("serif", Font.BOLD, 20);
              g.setColor(Color.black);
              g.setFont(font);
              g.drawString("Click on button to move the object.",80,350);
              Color c = Color.red;
              g.setColor(c);
              g.fillOval(200, 150, 155, 95);
    But from what my lecturer said I cannot use fixed variables for the oval. Also from wat you see there are some missing codes coz I do not know what should be written there.
    I'm sorry to cause any problems but I really need help...

  • Need Help for Java Homework Assignment, Can someone Please help me ?

    This is the program that I am supposed to write, and I am terrible confused, as it takes at least 3 different files.
    Write a class named GroceryList that representss a person's list of items to buy from the market, and another class named GroceryItemOrder that represents a request to purchase a particular item in a given quantity. (I.E. four boxes of cookies).
    **The GroceryList class should use an array field to store the grocery items, as well as keeping track of its size (number of items in the list so far). Assume that a grocery list will have no more than 10 items. A GrocerList object should have the following methods:
    public GroceryList()
    Constructs a new empty grocery list.
    public void add(GroceryItemOrder item)
    Adds the given item order to this list, if the list is not full (i.e., has fewer than 10 items).
    public double getTotalCost()
    Returns the total sum of all grocery item orders in this list.
    The GroceryItemOrder class should store an item quantity and a price per unit. A GroceryItemOrder object should have the following methods:
    public GrocerItemOrder(String name, int quantity, double pricePerUnit)
    Constructs an item order to purchase the item with the given name, in the given quantity, which costs the given pricer per unit.
    public double getCost()
    Returns the total cost of this item in its given quantity. I.E. 4 boxes of cookies that cost 2.30 per unit, have a total cost of 9.20.
    public void setQuantity(int quantity)
    Sets the grocery item's quantity to be the given value.
    Any suggestions would be sincerely appreciated.
    Thanks.

    Pete,
    I having difficulty with the main class, and getting console to store a users input into a string array ... I will post the code that I have so far. Sorry I am trying real hard to learn ... and just having a frustrating time.
    This is what I have in the main file.
    import java.util.*;
    public class Chapter_8 {
         public static void main(String []args){
              Scanner console = new Scanner(System.in);
              System.out.println("Please enter the first item of your list");
              String[]GroceryList = console.next();
              System.out.println("Please enter the next item of your list");
              String[]GroceryList = console.next();
              System.out.println("How many would you like to buy?");
              int quantity = consolenextInt();
         }This is what I have in the GroceryItem Class file:
    public class GroceryList{
    public GroceryList(){
    Static String []GroceryList ={"beans", "macaroni", "milk", "cheese", "bread", "eggs","hamburger","Hotdogs","peas","cookies"};
    for(int i=0;i<5;i++){
    System.out.println(GroceryList);
    And the final file that I have is the GroceryItemOrder Class file:public GroceryItemOrder(String name, int quantity, double pricePerUnit){
    this.name = name;
    this.quantity = quantity;
    this.pricePerUnit = pricePerUnit;
    public double getCost(){
    public void setQuantity(int quantity){
    Sorry, I know it isn't much, that's why I am frustrated.
    Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Help needed : DHCP not assigning addresses on VMware. click for more details.

    Hello people of technet,
    I'm new to this forum I was told I could get some help here. I need your help with an issue that I have on my network. As the title says, my DHCP server is not assigning addresses from a specific pool.
    Information about the topology:
    I have to sites linked with a VPN site to site connection. In the first site I have a DHCP Server, In the second site I have a client that should get an address automatically from the DHCP. I installed a DHCP relay agent on the server that manages the VPN
    connection on the second site with a correct configuration. All other configurations are done right I verified a couple of times. I checked the connectivity with a ping test between the client (with static address for the test) from the second site to the
    DHCP server from the first site, it is all working. The problem is that the DHCP server is not assigning addresses from the specific pool. All machines (4) run on windows server 2008 r2.
    Thank you for your time and support, just tell me if you need more informations.

    I fixed the problem it is working now, apparently it was the VMnet cards that caused the issue I've just reseted their configuration to default state. I've had the idea after you asked me to check DHCP address assignement on the same site. One more thing
    to do now, switch from the workgroup to a domain.
    Thank you for you time.

  • Help needed with this assignment

    Heres the question i have to complete.
    Build a new class LotsOfBooks which has an attribute which is an array of Book objects and initialises this array using a constructor method parameter. Write a method "setAllReserved" in LotsOfBooks which invokes setReserved( ) on all the books in the array.
    I have to submit my code into a Java compiler that tests my code against the teachers, if it is wrong you get given an error message. My code compiles fine in the compiler Blue J, but in the online tester i get this message.
    mismatch in setAllReserved
    Sometimes if i jig things about i get a null pointer error in the tester. I do not nesserseraly want a written java answer, just to know what i am doing wrong and what i can change.
    NB The array does not have to have any values and the Book class was already given.
    public class LotsOfBooks
    private Book[] books;
    public LotsOfBooks(Object Book[])
    public void setAllReserved()
    for (int i=0; i<books.length; i++){
    Book b =books;
    b.setReserved();
    public class Book
    String author;
    String title;
    boolean reserved;
    boolean onLoan;
    public Book(String author, String title){
    this.author = author;
    this.title = title;
    reserved = false;
    onLoan = false;
    public void setReserved(){
    reserved = true;
    public void setOnLoan(){
    onLoan = true;
    public boolean isOnLoan(){
    return onLoan;
    public String getAuthor(){
    return author;

    well for the preferred on i get
    DataSet 1
    ----------Compilation output--------------------------------------
    javac BookTester1.java
    BookTester1.java:18: cannot resolve symbol
    symbol : constructor LotsOfBooks (Book[])
    location: class LotsOfBooks
    LotsOfBooks lob = new LotsOfBooks(books);
    ^
    1 error
    ----------Sorry expected answer was-------------------------------
    The method setAllReserved worked OK - well done
    ----------Your answer however was---------------------------------
    ++ ERROR ++
    Your program did not compile
    Scroll back in this window to find more details
    [S] Sorry exercise ci101/Wk12BookA was not completed successfully
    and for if not i get
    DataSet 1
    ----------Compilation output--------------------------------------
    javac BookTester1.java
    ----------Sorry expected answer was-------------------------------
    The method setAllReserved worked OK - well done
    ----------Your answer however was---------------------------------
    Exception in thread "main" java.lang.ClassCastException
         at LotsOfBooks.<init>(LotsOfBooks.java:6)
         at BookTester1.main(BookTester1.java:18)
    [S] Sorry exercise ci101/Wk12BookA was not completed successfully

  • I need help with a java assignment

    I am being taught java but dont really understand what i have to do. If you send me an email to [email protected] ill send you a copy and so help me with the assignement.
    I am currently working on free web page so you can download the assignment.
    Thank You All

    hey, there's something wrong with my internet, i clicked on your email adress and nothing happened :(
    too bad. maybe i can't do your assignment.
    go see somee tutorials, maybe these will help you, also try to understand how API will elp you (to both you may find links from left column of this page) and also, see if there area some samples of how to do what you need to be done.
    http://www.javaalmanac.com -- my favorited place for code samples.
    also whan you have some saaignment or other task, then see if google finds you apropriate solution. and there's a search function in these forums as well.
    i hope you get your homework doen in time...

  • HT5271 Daughter's homework assignment needs adobe flash plug in.  Just got my new MacBook Pro and scare to download program if it compromises the security of laptop.  What do I do in this situation?

    Daughter's homework assignment needs adobe flash plug in.  Just got my new MacBook Pro and scare to download program if it compromises the security of laptop.  What do I do in this situation?

    OS X will automatically block versions of Flash that are known to be unsafe. As long as Flash is kept up to date, it's reasonably safe. You can minimize your exposure to Flash content by installing the "ClickToFlash" or "ClickToPlugin" Safari extension. Flash elements will then load only when clicked.

  • Help needed for assignment????

    Hi there everbody! Well I'm quite new to this, therfore I would greatly appreciated if some1 could help me with my assignment.
    Assignment:Make a Game applet that makes an object(red oval) move around the applet window by using only four buttons(Up, Right, Down, Left).
    I managed to do the button and the oval but both are not connected. Can some1 help me with the codes coz my assignment is due this week!!
    Here are what I've already done:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class Game extends Applet implements ActionListener{
    Button up1 = new Button("Up");
    Button down1 = new Button("Down");
    Button right1 = new Button("Right");
    Button left1 = new Button("Left");
    public void init() {
    Panel p = new Panel(new GridLayout(3, 3));
    p.setBackground(Color.white);
    p.add(new Label(""));
    p.add(up1);
    up1.addActionListener(this);
    p.add(new Label(""));
    p.add(left1);
    left1.addActionListener(this);
    p.add(new Label(""));
    p.add(right1);
    right1.addActionListener(this);
    p.add(new Label(""));
    p.add(down1);
    down1.addActionListener(this);
    add(p);
    public void actionPerformed(ActionEvent event) {
    repaint();
    public void paint(Graphics g) {
    Font font = new Font("serif", Font.BOLD, 20);
    g.setColor(Color.black);
    g.setFont(font);
    g.drawString("Click on button to move the object.",80,350);
    Color c = Color.red;
    g.setColor(c);
    g.fillOval(200, 150, 155, 95);
    As for the "g.fillOval(200, 150, 155, 95);" my lecturer told me that I should not use fix variables and I have to find out what the variables are so that the oval could move in the applet window upon clicking at the four buttons....I would be greatly appreciated if some1 could help me...

    Hi the main thing is you will need 2 classes, one for the applet, and one for the drawing panel.
    You create a class that extends Panel, call it PaintPanel and override paint(), which is where you do the drawing.
    In the applet you add your buttons, and the PaintPanel. When the buttons are clicked they change the state in the DrawPanel.
    The big thing to remember is you don't override paint() in the applet, only in your PaintPanel.

  • HELP NEEDED PLEASE

    Hi everyone
    Programming help needed here. Any advice would be greatly appreciated!!!
    I have been assigned some work for a program called Processing 1.0 availale at http://processing.org/download
    I was give the 9 individual programs I needed to make however they were converted to Java files from .pde files. The program is based on Java but only runs .pde files and NOTHING else!
    I decompiled the files and got the source code, but it is a slight variation of the original someone made in processing, and needs some tidying to get it to run.
    I think the programs are very simple for a programmer, although I AM NOT.
    CODE is BELOW
    // Decompiled by DJ v3.10.10.93 Copyright 2007 Atanas Neshkov Date: 02/05/2009 13:15:00
    // Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
    // Decompiler options: packimports(3)
    // Source File Name: Assign2_1.java
    import processing.core.PApplet;
    public class Assign2_1 extends PApplet
    public Assign2_1()
    SquareSide = 20;
    Rank = Nums.length;
    Side = SquareSide * Rank;
    Green = color(0, 255, 0);
    Yellow = color(255, 255, 0);
    BG = Yellow;
    public void setup()
    size(Side, Side);
    background(BG);
    fill(Green);
    for(int i = 0; i < Rank; i++)
    rect(i * SquareSide, 0.0F, SquareSide, SquareSide * Nums);
    public static void main(String args[])
    PApplet.main(new String[] {
    "--bgcolor=#ece9d8", "Assign2_1"
    int Nums[] = {
    6, 14, 8, 9, 2, 3, 4, 2, 8, 3,
    9, 2, 0, 5
    int SquareSide;
    int Rank;
    int Side;
    int Green;
    int Yellow;
    int BG;
    Edited by: chevy1 on May 2, 2009 7:32 AM

    HELP NEEDED PLEASEShouting is a good way ensure you don't get help. Also you should give a meaningful subject.
    Any advice would be greatly appreciated!!!I suggest you ask a question after providing enough information to be able to answer it.
    Also use CODE tags when posting code as it make the code more readable.
    We are more likely to help people who are trying to learn Java rather than someone who might be looking for an easy way out of doing an assignment.

  • Help me with  this assignment

    can anyone out there help me with this assignment ????? i`ll attach the file to this topic
    In this assignment, you are to write a Java applet, using arrays, to simulate the functions of a drinks-vending machine.
    The assignment requirements described below are broken down into 2 stages of development, described in this document
    as 'Basic Requirements' and 'Additional Features'. You are advised to do your programming progressively in these
    stages. An Activity Plan has also been specified for you to follow. Refer to the 'Grading Criteria' on page 5 to have
    an idea of how the different components are graded.
    1.     1. BACKGROUND
    A company intends to build computerised drinks-vending machines to enlarge its business portfolio. You have been tasked to develop a
    Java applet that simulates the operation of such a machine to determine if it will meet their needs.
    2.     1. BASIC REQUIREMENTS
    The machine should have a wide range of drinks available. A customer can choose a drink according to the following criteria:
    a)     a) Category of Drinks
    �     � Beverages
    �     � Soft Drinks
    (For beverages, there is choice of whether sugar and/or creamer is required, for which there is an additional charge.)
    b)     b) Type of Beverages
    �     � Hot
    �     � Cold
    Once a customer has specified the drink he wants, the amount payable is displayed. The unit prices to be displayed are as follows:
    Drinks     Price per Cup/Packet ($)
    Beverage:     Coffee     1.00
         Tea     1.20
         Milo     1.40
         Horlicks     1.35
         Chrysanthemum     1.00
         Ginger     0.80
    Soft Drinks:     Apple     1.40
         Orange     1.40
         Pineapple     1.50
         Carrot     2.00
         Longan     1.20
         Bandung     1.00
    (For beverages, a request for sugar or creamer attracts an additional charge of $0.10 each. Creamer is not applicable for
    chrysanthemum and ginger.)
    The customer may then confirm his order by entering the amount payable (this symbolises his payment for the drink). Whenever the
    payment input is not correct, an appropriate error message is displayed, whereupon the customer has to re-enter the amount again.
    When the correct amount is paid, the required drink is dispensed.
    For any drink that is out of stock, a message is shown, stating that it is not available. Each time a drink is dispensed, the stock for that
    drink is updated (For beverages, the stock is stored in units of servings for each cup.) To simplify the testing, you may start the simulation
    by setting the stock for each drink to 10 packets or cup-servings.
    3.     2. ADDITIONAL FEATURES
    In addition, the simulator can have the following features:
    a)     a) Smart Graphical User-Interface (GUI)
    You may build upon the basic requirements by recommending alternative drinks of the same category, whenever a requested
    drink is not available (as signified from the stock). In this case, only drinks which are available (i.e., in sufficient stock) are
    displayed for the customer to choose. And if only soft drinks are available, the selections for creamer and sugar should be disabled.
    b)     b) Multiple Orders
    A customer could order more than one drink. The system could allow him to specify as many drinks as he wants, prompting him
    for an appropriate payment, and then dispensing the drinks accordingly, subject to availability. This may also entail the extension
    of the graphical user-interface.
    c)     c) Sales Analysis
    Periodically, the total revenue accumulated since the last collection is printed in descending order of sales for each drink sold,
    together with a grand total. The cash is then cleared from the machine. This feature requires password-protection.
    d)     d) Replenishment of Stock
    Periodically, the stock is checked to determine how much of each drink needs to be replenished. For this purpose, a list of the
    drinks with the corresponding quantity on hand is printed in ascending order of stock level. Drinks with insufficient stock are
    topped up to a level of 10 servings or packets. This feature also requires password-protection.
    e)     e) Any other relevant features
    You are limited only by your creativity. You can add any other relevant features for this project. Please consult your tutor before
    you proceed.
    To qualify for the full marks for this section, you need to implement 2 features, at least one of which must be either (a) or (b) above.
    4.     3. ACTIVITY PLAN
    Suggestions for Getting Started
    There are many ways that you could complete this assignment. The most important part is to think about the entire project first so that
    it is easy to integrate the various pieces. You should also consider what type of graphics you want to incorporate.
    a)     a) Analysis
    1. Understand the program specification and the requirements before attempting the project.
    b)     b) Program Design
    2.     Work out the GUI components (e.g., TextFields, CheckBoxes, ChoiceBoxes, Buttons, etc.) needed to get the user input.
    3.     3. Work out the main logic of the program using modular programming techniques; i.e. use methods appropriately. E.g., tasks that perform
    4.     4. a well-defined function or those that are repeated should be coded as methods. For example, you can write the methods, displayBill(),
    5.     5. makePayment(), computeTotal(), dispenseDrink(), etc. You need to think carefully about the return type and the parameters of each
    6.     6. method.
    7.     7. You are required to use arrays appropriately for this assignment. Marks will be deducted for inefficient use or non-usage of arrays.
    c) Implementation & Testing
    8.     8. Write the method definition of each method ONE at a time.
    9.     9. Test your program logic to make sure that it works. In the interim, you can use �g.drawString(�);� or �System.out.println(�);� to print
    10.     10. out intermediate results so that you can see whether your program is working correctly. You may not want to bother about error-checking
    11.     11. at this point. You should test each method as soon as it is written, as it is much easier to debug your program in this way.
    5.     4. DELIVERABLES
    By Monday, 25th February before 5:00 p.m., hand in the following to the School of ICT Administrative Office at Block 31, level 8:
    �     � A copy of the printout of your .java file.
    �     � A diskette labelled with your name, group, student ID. The diskette should contain ALL the necessary files (.java, .html, and .class)
    to run your applet.
    �     � The above in an envelope topped with the Assignment Completion Report (see pages 6, 7 & 8). Page 6 is for you to paste on top
    of your envelope whilst pages 7 and 8 are for you to document your Test Plan, and write your comments (including any
    special instructions to run your program) - to be inserted into the envelope.
    In your .java program, you are to include a blocked comment at the top stating:
    q     q Your name, group, student ID.
    q     q Assumptions (if any) or any deviations from the specified requirements.
    q     q Any features that you would like to highlight.
    6.     5. WALK-THROUGH OF PROGRAM
    Monday 25th February at 9:30 a.m. SHARP
    In the walk-through, you will be asked to give short, written answers to some questions about your program. These questions will assess
    your basic understanding of the code that you are handing in. If you fail to display adequate understanding of your own program, you can
    be down-graded by up to two letter grades from what you would have normally received. It is also possible that you will be called to
    perform a demonstration cum explanation of your work if it is suspected that you have copied someone else�s work. Lesson: do your own
    work and you will have no problem!
    7.     6. GRADING CRITERIA FOR PROGRAMMING
    Correct and robust implementation of basic features     55 %
    Additional features     20 %
    Programming style:�     � Program design�     � Appropriate use of arrays�     � Appropriate use of variables, methods, and parameters�     � Proper usage of control structures (e.g. if/else, loops)     15 %
    Good programming practice:�     � Meaningful variable names �     � Proper indentations�     � Useful and neat comments     5 %
    Adequate (black-box) testing:�     � Suitably-designed test plan     5 %
    Total:     100 %
    PROBLEM SOLVING & PROGRAMMING II
    (Dip IT/MMC/EI, Year 1, Semester 2)
    Assignment Completion Report (to be attached to cover of envelope)
    Name: ___________________________________ Group: ________
    ID: ___________________ Date & Time submitted: ____________
    Requirements     % Done (0-100)     Remarks
    BASIC FEATURES          
    �     � Can choose category (and select appropriate additives)          
    �     � Can choose drink (with error checking)          
    �     � Can display amount payable          
    �     � Can indicate availability of drink (with error checking)          
    �     � Can accept payment for drink (with error checking)          
    �     � Can dispense drink          
    �     � Can update stock          
    ADDITIONAL FEATURES          
    �     � Smart GUI          
    �     � Multiple Orders          
    �     � Sales Analysis (with password checking)          
    �     � Stock Replenishment(with password checking)          
    �     � Any other relevant features          
    Test Plan
    Using black-box testing, record your test specification and the results according to the following format (the examples here are provided
    for your reference only):
    Test No.     Purpose     Test Shot/Data     Expected Result     Actual Result
    E.g. 1a)     Check whether beverage can be selected      Click on �Chrysanthe-mum� button     Checkbox for �Sugar� but not �Creamer� appear     �Sugar� and checkboxes appeared
    E.g. 1b)     Check whether chrysanthemum with sugar can be ordered      Select sugar and click on �Order� button     Amount payable appears as �$1.10� (i.e., $1.00 + $0.10)     Amount payable shown as $1.10
    E.g. 1c)     Check whether correct payment can be accepted      Enter �1.00� in �Payment� textfield     Error message �Insufficient payment - $0.10 short� appears     Confirmation message �Drink being dispensed� appeared � ERROR!
    E.g. 1d)     Re-test 1c), after amending program      As above     As above     Error message �Insufficient payment - $0.10 short� appeared
    etc.                    
    etc.                    
    Remember to hand in this test plan together with the other deliverables in the envelope.
    Have you�
    1.     1. Checked to make sure program still works properly even with windows resized?
    2.     2. Tested your program thoroughly, as if you're trying to break it?
    Any comments about this assignment? Any special instructions to run your program? Write it here.

    public class testing1 {
    String gg;
    public void testing3() {
    System.out.print(gg); }
    // this is are constructor for the object and method we are going to make
    next code
    class testing {
    public static void main(String[] args) {
    testing1 tes = new testing1();
    tes.gg = "hello there";
    tes.testing3(); //here we have made a object and a method
    hope this helps

  • How to create Search help exit, and then assign it to a collective search

    hi gurus,
    i have an intersting question for you, well my scenario is like i have to create a search help exit using some function module cause i didt found table for my search help but i can find the value through FM, i know we can create a search help exit and then assign it to collective search help,
      my problem is what are the parameters i need to pass to this search help exit FM, and in the function module i want to use the value entered on the f4 selection screen to extract data through FM. i need to give a solution  asap.
    any reply will be highly appreciated
    n rewards points for sure.
    thanks mandy

    Hi mandy,
    Have a look at this code,
    FUNCTION SHLP_SHOW_LIST.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(PLANT) TYPE  WERKS_D OPTIONAL
    *"     VALUE(DISPLAY_ONLY) TYPE  FLAG OPTIONAL
    *"  EXPORTING
    *"     REFERENCE(ITEM_SELECTED) TYPE  CHAR20
    *"  EXCEPTIONS
    *"      POPUP_CANCELED
    TYPE-POOLS SHLP .
    CONSTANTS:
            co_shlpname            TYPE shlpname   VALUE 'SHLP_CONTAINER',
            co_shlpfield_itemalias TYPE ddshlpsfld VALUE 'CONTAINER'.
      DATA: l_shlp         TYPE shlp_descr_t,
            l_subrc        TYPE sysubrc,
            l_return_tab   TYPE STANDARD TABLE OF ddshretval,
            l_return_wa    TYPE ddshretval,
            l_interface_wa TYPE ddshiface.
    Get details for search help
      CLEAR l_shlp.
      l_shlp-shlpname  = co_shlpname.
      l_shlp-shlptype  = 'SH'.
      CALL FUNCTION 'DD_SHLP_GET_HELPMETHOD'
           CHANGING
                shlp = l_shlp.
    Assign virtual screen field
      READ TABLE l_shlp-interface INTO l_interface_wa
      WITH KEY shlpfield = co_shlpfield_itemalias.
      l_interface_wa-value      = space.
      l_interface_wa-valtabname = 'X2'.    "virtuel screen field
      l_interface_wa-valfield   = 'Y2'.    "virtuel screen field
      MODIFY l_shlp-interface FROM l_interface_wa INDEX sy-tabix.
    Call F4 popup
      CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
           EXPORTING
                shlp          = l_shlp
                disponly      = display_only
           IMPORTING
                rc            = l_subrc
           TABLES
                return_values = l_return_tab
           EXCEPTIONS
                OTHERS        = 0.
      IF sy-subrc = 0 AND l_subrc = 0.
      Value selected
        READ TABLE l_return_tab INDEX 1 INTO l_return_wa.
        item_selected = l_return_wa-fieldval.
      ELSE.
      Popup canceled / no value selected
        RAISE popup_canceled.
      ENDIF.
    ENDFUNCTION.
    make sure to call these FMs and populate accordingly...
    Thanks
    Madhu

  • FM account assignments need to be assigned for each grantee year

    Hi experts!!
    I have a problem when i execute GM_REVAL (Revaluation of Currency for Grants Management). System gets an errror: FM account assignments need to be assigned for each grantee year (Message no. GRANTMGMT363).
    I've customized FMDERIVE in order to derive Fund center, commitment item, grant and fund. And GMDERIVE to derive Sponsor Program and Sponsor class. In a FI postings (FB01 or FBCJ), these derivations works ok.
    Anyone knows how can i solve this error?
    Thank you.

    Hello Dolors,
    for the revaluation you need to maintain default FM settings in the
    customizing. See IMG - GM - master data - revaluation. Note that these
    FM master data objects must be valid throughout the budget validity
    period.
    I hope this helps..
    Best regards,
    Mar.

  • HELP! trying to assign values to lists

    project: is to make a java program that allows the a user (student) to drag and drop classes into a scheduler maker for fall or spring semesters. need to assign a value somehow to each class that is added to a semester so we can limit the student to say 12 hours total (each class has a value of 3 hours)
    Need help knowing how to assign each class a value of 3 and how to limit them to 12 hours for each semester?
    i'll put part of the the code below:
                        //---- tree1 ----
                        tree1.setModel(new DefaultTreeModel(
                             new DefaultMutableTreeNode("Information Science Requirements") {
                                       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Core");
                                            node1.add(new DefaultMutableTreeNode("English Composition"));
                                            node1.add(new DefaultMutableTreeNode("Fine Arts/Humanities"));
                                            node1.add(new DefaultMutableTreeNode("Social Sciences"));
                                            node1.add(new DefaultMutableTreeNode("Technical Writing"));
                                            node1.add(new DefaultMutableTreeNode("History"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("IFSC");
                                            node1.add(new DefaultMutableTreeNode("1110"));
                                            node1.add(new DefaultMutableTreeNode("1201"));
                                            node1.add(new DefaultMutableTreeNode("1202"));
                                            node1.add(new DefaultMutableTreeNode("1305"));
                                            node1.add(new DefaultMutableTreeNode("1310"));
                                            node1.add(new DefaultMutableTreeNode("2300"));
                                            node1.add(new DefaultMutableTreeNode("2305"));
                                            node1.add(new DefaultMutableTreeNode("2315"));
                                            node1.add(new DefaultMutableTreeNode("2340"));
                                            node1.add(new DefaultMutableTreeNode("3305"));
                                            node1.add(new DefaultMutableTreeNode("3315"));
                                            node1.add(new DefaultMutableTreeNode("3320"));
                                            node1.add(new DefaultMutableTreeNode("3330"));
                                            node1.add(new DefaultMutableTreeNode("3360"));
                                            node1.add(new DefaultMutableTreeNode("4210"));
                                            node1.add(new DefaultMutableTreeNode("4310"));
                                            node1.add(new DefaultMutableTreeNode("4396"));
                                            node1.add(new DefaultMutableTreeNode("4398"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("MATH");
                                            node1.add(new DefaultMutableTreeNode("1451"));
                                            node1.add(new DefaultMutableTreeNode("1452"));
                                            node1.add(new DefaultMutableTreeNode("2310"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("STAT");
                                            node1.add(new DefaultMutableTreeNode("3352"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("PHYS");
                                            node1.add(new DefaultMutableTreeNode("2321"));
                                            node1.add(new DefaultMutableTreeNode("2121"));
                                            node1.add(new DefaultMutableTreeNode("2322"));
                                            node1.add(new DefaultMutableTreeNode("2122"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("ACCT");
                                            node1.add(new DefaultMutableTreeNode("2310"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("MKGT");
                                            node1.add(new DefaultMutableTreeNode("3350"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("MGMT");
                                            node1.add(new DefaultMutableTreeNode("3300"));
                                            node1.add(new DefaultMutableTreeNode("4331"));
                                            node1.add(new DefaultMutableTreeNode("4361"));
                                       add(node1);
                        tree1.setVisibleRowCount(5);
                        scrollPane1.setViewportView(tree1);
                   class_scheduler.add(scrollPane1, new GridBagConstraints(1, 5, 9, 10, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                        new Insets(0, 0, 5, 5), 0, 0));
                   //---- label6 ----
                   label6.setText("Available Courses");
                   label6.setFont(label6.getFont().deriveFont(label6.getFont().getStyle() | Font.ITALIC));
                   class_scheduler.add(label6, new GridBagConstraints(11, 5, 5, 1, 0.0, 0.0,
                        GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 5, 5), 0, 0));
                   //======== scrollPane3 ========
                        scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
                        scrollPane3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                        //---- list2 ----
    DefaultListModel listModel2 = new DefaultListModel();
    listModel2.addElement("IFSC 1110");
    listModel2.addElement("IFSC 1201");
    listModel2.addElement("IFSC 1202");
    listModel2.addElement("IFSC 1305");
    listModel2.addElement("IFSC 1310");
    listModel2.addElement("IFSC 2300");
    listModel2.addElement("IFSC 2305");
    listModel2.addElement("IFSC 2315");
    listModel2.addElement("IFSC 2340");
    listModel2.addElement("IFSC 3305");
    listModel2.addElement("IFSC 3315");
    listModel2.addElement("IFSC 3320");
    listModel2.addElement("IFSC 3330");
    listModel2.addElement("IFSC 3360");
    listModel2.addElement("IFSC 4210");
    listModel2.addElement("IFSC 4310");
    listModel2.addElement("IFSC 4396");
    listModel2.addElement("IFSC 4398");
    listModel2.addElement("MATH 1451");
    listModel2.addElement("MATH 1452");
    listModel2.addElement("MATH 2310");
    listModel2.addElement("STAT 3352");
    listModel2.addElement("PHYS 2321");
    listModel2.addElement("PHYS 2121");
    listModel2.addElement("PHYS 2322");
    listModel2.addElement("PHYS 2122");
    listModel2.addElement("ACCT 2310");
    listModel2.addElement("MKGT 3350");
    listModel2.addElement("MGMT 3300");
    listModel2.addElement("MGMT 4331");
    listModel2.addElement("MGMT 4361");
    list2 = new JList(listModel2);
    list2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list2.setDragEnabled(true);
    list2.setTransferHandler(new ListTransferHandler());
    list2.setDropMode(DropMode.INSERT);
                        scrollPane3.setViewportView(list2);
                   class_scheduler.add(scrollPane3, new GridBagConstraints(11, 6, 17, 4, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                        new Insets(0, 0, 5, 5), 0, 0));

    project: is to make a java program that allows the a user (student) to drag and drop classes into a scheduler maker for fall or spring semesters. need to assign a value somehow to each class that is added to a semester so we can limit the student to say 12 hours total (each class has a value of 3 hours)
    Need help knowing how to assign each class a value of 3 and how to limit them to 12 hours for each semester?
    i'll put part of the the code below:
                        //---- tree1 ----
                        tree1.setModel(new DefaultTreeModel(
                             new DefaultMutableTreeNode("Information Science Requirements") {
                                       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Core");
                                            node1.add(new DefaultMutableTreeNode("English Composition"));
                                            node1.add(new DefaultMutableTreeNode("Fine Arts/Humanities"));
                                            node1.add(new DefaultMutableTreeNode("Social Sciences"));
                                            node1.add(new DefaultMutableTreeNode("Technical Writing"));
                                            node1.add(new DefaultMutableTreeNode("History"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("IFSC");
                                            node1.add(new DefaultMutableTreeNode("1110"));
                                            node1.add(new DefaultMutableTreeNode("1201"));
                                            node1.add(new DefaultMutableTreeNode("1202"));
                                            node1.add(new DefaultMutableTreeNode("1305"));
                                            node1.add(new DefaultMutableTreeNode("1310"));
                                            node1.add(new DefaultMutableTreeNode("2300"));
                                            node1.add(new DefaultMutableTreeNode("2305"));
                                            node1.add(new DefaultMutableTreeNode("2315"));
                                            node1.add(new DefaultMutableTreeNode("2340"));
                                            node1.add(new DefaultMutableTreeNode("3305"));
                                            node1.add(new DefaultMutableTreeNode("3315"));
                                            node1.add(new DefaultMutableTreeNode("3320"));
                                            node1.add(new DefaultMutableTreeNode("3330"));
                                            node1.add(new DefaultMutableTreeNode("3360"));
                                            node1.add(new DefaultMutableTreeNode("4210"));
                                            node1.add(new DefaultMutableTreeNode("4310"));
                                            node1.add(new DefaultMutableTreeNode("4396"));
                                            node1.add(new DefaultMutableTreeNode("4398"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("MATH");
                                            node1.add(new DefaultMutableTreeNode("1451"));
                                            node1.add(new DefaultMutableTreeNode("1452"));
                                            node1.add(new DefaultMutableTreeNode("2310"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("STAT");
                                            node1.add(new DefaultMutableTreeNode("3352"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("PHYS");
                                            node1.add(new DefaultMutableTreeNode("2321"));
                                            node1.add(new DefaultMutableTreeNode("2121"));
                                            node1.add(new DefaultMutableTreeNode("2322"));
                                            node1.add(new DefaultMutableTreeNode("2122"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("ACCT");
                                            node1.add(new DefaultMutableTreeNode("2310"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("MKGT");
                                            node1.add(new DefaultMutableTreeNode("3350"));
                                       add(node1);
                                       node1 = new DefaultMutableTreeNode("MGMT");
                                            node1.add(new DefaultMutableTreeNode("3300"));
                                            node1.add(new DefaultMutableTreeNode("4331"));
                                            node1.add(new DefaultMutableTreeNode("4361"));
                                       add(node1);
                        tree1.setVisibleRowCount(5);
                        scrollPane1.setViewportView(tree1);
                   class_scheduler.add(scrollPane1, new GridBagConstraints(1, 5, 9, 10, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                        new Insets(0, 0, 5, 5), 0, 0));
                   //---- label6 ----
                   label6.setText("Available Courses");
                   label6.setFont(label6.getFont().deriveFont(label6.getFont().getStyle() | Font.ITALIC));
                   class_scheduler.add(label6, new GridBagConstraints(11, 5, 5, 1, 0.0, 0.0,
                        GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL,
                        new Insets(0, 0, 5, 5), 0, 0));
                   //======== scrollPane3 ========
                        scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
                        scrollPane3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                        //---- list2 ----
    DefaultListModel listModel2 = new DefaultListModel();
    listModel2.addElement("IFSC 1110");
    listModel2.addElement("IFSC 1201");
    listModel2.addElement("IFSC 1202");
    listModel2.addElement("IFSC 1305");
    listModel2.addElement("IFSC 1310");
    listModel2.addElement("IFSC 2300");
    listModel2.addElement("IFSC 2305");
    listModel2.addElement("IFSC 2315");
    listModel2.addElement("IFSC 2340");
    listModel2.addElement("IFSC 3305");
    listModel2.addElement("IFSC 3315");
    listModel2.addElement("IFSC 3320");
    listModel2.addElement("IFSC 3330");
    listModel2.addElement("IFSC 3360");
    listModel2.addElement("IFSC 4210");
    listModel2.addElement("IFSC 4310");
    listModel2.addElement("IFSC 4396");
    listModel2.addElement("IFSC 4398");
    listModel2.addElement("MATH 1451");
    listModel2.addElement("MATH 1452");
    listModel2.addElement("MATH 2310");
    listModel2.addElement("STAT 3352");
    listModel2.addElement("PHYS 2321");
    listModel2.addElement("PHYS 2121");
    listModel2.addElement("PHYS 2322");
    listModel2.addElement("PHYS 2122");
    listModel2.addElement("ACCT 2310");
    listModel2.addElement("MKGT 3350");
    listModel2.addElement("MGMT 3300");
    listModel2.addElement("MGMT 4331");
    listModel2.addElement("MGMT 4361");
    list2 = new JList(listModel2);
    list2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list2.setDragEnabled(true);
    list2.setTransferHandler(new ListTransferHandler());
    list2.setDropMode(DropMode.INSERT);
                        scrollPane3.setViewportView(list2);
                   class_scheduler.add(scrollPane3, new GridBagConstraints(11, 6, 17, 4, 0.0, 0.0,
                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                        new Insets(0, 0, 5, 5), 0, 0));

  • Help Needed on a java program

    I am very new to java and our teacher has given us a program
    that i am having quite a bit of trouble with. I was wondering if anyone could help me out.
    This is the program which i have bolded.
    {You will write a Java class to play the TicTacToe game. This program will have at least two data members, one for the status of the board and one to keep track of whose turn it is. All data members must be private. You will create a user interface that allows client code to play the game.
    The user interface must include:
    � Boolean xPlay(int num) which allows x to play in the square labeled by num. This function will return true if that play caused the game to end and false otherwise.
    � Boolean oPlay(int num) which allows o to play in the square labeled by num. This function will return true if that play caused the game to end and false otherwise.
    � Boolean isEmpty(int num) will check to see if the square labeled by num is empty.
    � Void display() which displays the current game status to the screen.
    � Char whoWon() which will return X, O, or C depending on the outcome of the game.
    � You must not allow the same player to play twice in a row. Should the client code attempt to, xPlay or oPlay should print an error and do nothing else.
    � Also calling whoWon when the game is not over should produce an error message and return a character other than X, O, or C.
    � Client code for the moment is up to you. Assume you have two human players that can enter the number of the square in which they want to play.
    Verifying user input WILL be done by the client code.}

    This is the program which i have bolded.Hmmm, that doesn't look like any programming language I've ever seen. I guess you have the wrong forum here, because it isn't Java.
    That looks like a natural-language programming language that directly understands a homework assignment. Either that, or you really did just post the assignment. You wouldn't have done that though, right?

Maybe you are looking for