can anyone help me with this school project?
they want me to create something like this :
using Net income = Revenue - costs - salary
net income percentage is by multiplying (Net income)/(Revenue Ratio) with 100%

Handphone net income computation
-----------------------------------
1. Press A to enter Revenue and Costs
2. Press B for Net Income
3. Press C to exit
please enter selection :

Option A
--------
Revenue <please enter 2 dec places > :
Costs <please enter 2 dec places > :
Salary <please enter 2 dec places > :

Handphone net income computation
-----------------------------------

Option B
--------
items amount<$> percentage<%>
----- ----------- ---------------
Revenue (numbers)
Cost (numbers)
Salary (numbers)
====== ========== ============
net income (final answer) (final percentage)


Handphone net income computation
-----------------------------------
1. Press A to enter Revenue and Costs
2. Press B for Net Income
3. Press C to exit
please enter selection : Y <---------(wrong selection)

please enter A, B, or C only.

Handphone net income computation
-----------------------------------
1. Press A to enter Revenue and Costs
2. Press B for Net Income
3. Press C to exit
please enter selection :

umm someone PLEASE HELP ME!

Nobody is going to baby you through your projects. Start by asking some specific questions. If you don't know any Java programming I suggest you read a tutorial or three.

Try creating the menu and sub menus first, so that they correctly reflect what the description specifies. Once you have done this you could later on move to the calculation and output part.

Use the Scanner class to take user input.

yes i did
i'll post the part i did :

import java.text.*;
import java.util.*;

public class Exam {

   static Scanner input=new Scanner(System.in).useDelimiter("\r\n");

   static DecimalFormat fmt=new DecimalFormat("0.00");

   static Double[] result = new Double [10];

   static Double[] Revenue = new Double [10];

   static Double[] Costs = new Double [10];

   static Double[] Salary = new Double [10];

   static String[] type= new String [10];



   static int choice, f=0;


   static char selection, select;

    public static void main(String[] args)throws Exception 
    {

    do
    { 
    System.out.println();
    System.out.println("Handphone Net Income Computation");
    System.out.println("========================");
    System.out.println("1. Press A to enter Revenue and Costs ");
    System.out.println("2. Press B for Net Income");
    System.out.println("3. Press C to exit");
    System.out.print("Please enter selection : ");
   choice=input.nextInt();

    switch(choice)
    {



       case 1: firsttest();
    break;     

      case 2: summary();
break;






default: System.out.println();
System.out.println("Please enter A, B or C only.\n");
  break;   

  }

    }while(choice!= 3);

    }//end of main

    static void firsttest() throws Exception{




    System.out.println();
   System.out.println();
    System.out.println("Option A");
    System.out.println("--------");


   System.out.print("Revenue <Please enter 2 dec places> : ");
            Revenue[f]=input.nextDouble();

            System.out.print("Cost of handphone <Please enter 2 dec places> : ");
            Costs[f]=input.nextDouble();

            System.out.print("Salary <please enter 2 dec places> : " );
            Salary[f]=input.nextDouble();


            selection=(char)System.in.read();
    System.in.read();
   System.in.read();

    }
static void summary() throws Exception{

    result[f]=Revenue[f] - Costs[f] - Salary[f];

Edited 3 Years Ago by Dani: Formatting fixed

and im stuck right now
i cant make the Revenue - cost - salary calculation thingy

Firstly you need to increment the variable 'f' or else all values are going to go to the index position of the array, since f is initially 0.

When you need to calculate the result for the values just loop through the arrays with

for(int i=0;i<f;i++){
     result[i]=Revenue[i] - Costs[i] - Salary[i]; 
}

Firstly you need to increment the variable 'f' or else all values are going to go to the index position of the array, since f is initially 0.

When you need to calculate the result for the values just loop through the arrays with

for(int i=0;i<f;i++){
     result[i]=Revenue[i] - Costs[i] - Salary[i]; 
}

i still cant get it to show the calculations
i think its my positioning that is wrong
i dont know how

The same way that you have made the original menu, you can make the sub menus. So that when the menu choice A is selected you show the sub-menus for A and same for B.

but if you do that, don't use:

switch(choice){
  case 1: //your code
              break;
  case 2: // your code
              break;
  case 3: // your code
              break;
}

simply, because if you enter 'A', 'B' or 'C', the switch will never have
the values '1' '2' or '3'.

This article has been dead for over six months. Start a new discussion instead.