954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how do i make this program?

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 :
Costs :
Salary :

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!

weinyeong
Newbie Poster
6 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

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.

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 

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.

verruckt24
Posting Shark
952 posts since Nov 2008
Reputation Points: 485
Solved Threads: 89
 

im stuck at the part which i cant put the choices A B or C

weinyeong
Newbie Poster
6 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

Did you write any code yet?

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 

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 : ");
Revenue[f]=input.nextDouble();

System.out.print("Cost of handphone : ");
Costs[f]=input.nextDouble();

System.out.print("Salary : " );
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];

weinyeong
Newbie Poster
6 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

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

weinyeong
Newbie Poster
6 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

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]; 
}
verruckt24
Posting Shark
952 posts since Nov 2008
Reputation Points: 485
Solved Threads: 89
 

And use code tags. Read the forum rules.

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 

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

weinyeong
Newbie Poster
6 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

and how do i make my case 'A' and 'B'?
i suck at this

weinyeong
Newbie Poster
6 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

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.

verruckt24
Posting Shark
952 posts since Nov 2008
Reputation Points: 485
Solved Threads: 89
 

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'.

stultuske
Posting Sensei
3,110 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 432
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You