Help in calculating a ratio
Good afternoon forum,
I have a problem when calculating a ratio.
It turns out that I have the following data:
Center Material Stock
C1 x1 5
C1 x2 2
C2 x1 7
C2 x2 6
And make needed in the following calculation.
Sum of all ratios of stock Nº Centers) ...
In my case would be 26 2 = 13
Someone I could lend a hand ...
The logic presented by Rakesh seems to be appropriate .
u need to follow and utilise the Boolean operators...
go to query designer
lets say the ratio u need to display is in columns
now right clik and say new formulae
from there select the Formulae operator as Boolean operators
use follwong formulae
WORK IN PROGRESS = (actual cost > cost periodificado) * (actual cost - cost periodificado)
PROVISION IN SPENDING = (actual cost < cost periodificado) * ( cost periodificado - actual cost)
Hit okey
go to actual costs properties
put the display option as HIDE
repeat the same for Cost periodificado
go to query properties
use the option SUPRESS ZERO VALUES FOR rows and columns....
this way u will only display the required result
Similar Messages
-
I need your help in calculation script: Using 9.3.1 version
In below script , I have to write same code for total 10 account members used in the same place A and all 10 accounts members are level 0 children of 1 parent.
A = A + B / C*D
I need to write a code where 10 Account members can be used during calculation in place of A.
Please can you help me on this query .. How to achieve this requirement ...
Regards
VishalUsing my Very Favorite Essbase Database In The Whole Wide World, aka Sample.Basic, I wrote the following nonsense code snippet:
FIX(@RELATIVE("Profit", 0), @LEVMBRS("Product", 0), @LEVMBRS("Market", 0), @LEVMBRS("Year", 0))
"Actual" = "Actual" + "Actual"->"Opening Inventory" / "Actual"->"Additions" * "Actual"->"Ending Inventory" ;
ENDFIXDon't focus on why you would never ever want to do the above with inventory, just look at the code.
The code does work.
Before:
100-10 New York Actual
Jan Sales 679
COGS 271
Margin 408
Marketing 94
Payroll 51
Misc 0
Total Expenses 145
Profit 263
Opening Inventory 2101
Additions 644
Ending Inventory 2066 After
100-10 New York Actual
Jan Sales 7419.164596
COGS 7011.164596
Margin 408
Marketing 6834.164596
Payroll 6791.164596
Misc 6740.164596
Total Expenses 20365.49379
Profit -19957.49379
Opening Inventory 2101
Additions 644
Ending Inventory 2066 I can't remember if your to be affected members are under a common parent or not. If the latter, use a UDA to go after the members.
Oh yes, this code violates one of my personal design considerations -- it modifies the source data so it can only be run once. That is really dangerous but the choice is yours.
Regards,
Cameron Lackpour -
We have a db with 6 dimensions:Accounts (dense)Time (12 months aggregated into 4 quarters - set with DTS for YTD and QTD) - Dynamic calc on QtrScenario (Actual 03, Actual 02, Plan 1 03, Plan 2 03 etc)Cost CentreBusinessAnalysis codeOur customer has devised some ratios that can Fall over into previous years - example :Average Income - MTD = (last month AI + this month AI) / 2QTD = (last month of previous quarter + current months of quarter) / (1 + months of current quarter) Note: this means if it is February then calc should be (December + January + February) / (1 + 2). If it was for April then it would be (March + April) / (1 + 1).YTD = (last month of previous year + current months of this year) / ( 1 + current months of this year) Note: this would be as per February example shown for QTD above.The issue is that this would mean that we would have to either calculate all these as fixed results by a long calculation string (bearing in mind that you have to use 2 different scenarios), or by some clever outline set up.Does this mean that we would have to introduce a new dimension for years, and amend the scenario so that it referred to the process e.g. Actual, Plan 1, Plan 2 ?A further complication is that Plan 1 in 03 covers all 12 months for 2003 and also 12 months for 2004. Plan 2 covers last 6 months of current year, plus 12 months for 2004, 12 months for 2005 and 12 months for 2006.Also, how can we get it to work so that the user can specify which month they are looking at and still return the correct answers.Any information / suggestions would be fantastic, as they sprung this upon us yesterday, and we have 3 days to get it in and working !!
Are you using Essbase 6.5.1 or above? This version introduced some new calc fucntions that help calcualting ranges across two dimensions - @XRANGE and @MOVSUMX
-
Help with calculations in XMLP Template
Hi,
I would like to get some guidance on how the below could be done in XMLP. I am getting the 'Amount' column from FSG and would like to calculate the percentage in the template. Is it possible to calculate rows and store results in column like in the example below in XMLP? Many thanks for your help.
Type-------Amount-----%
Gross-----------10-----166.7 (Gross/Net*100)
Discount---------4-------66.7 (Discount/Net*100)
======================
Net (G-D)--------6-----100.0 (Net/Net*100) or (Gross% - Discount%)Hi Hazan,
I have done a similar Gross Margin Report using XMLP 5.5.
I have used the concept of variables to store temporary values in my report and carry out complex calculations.
Please let me know what version of XMLP are you using?
Some of my form fields containing variables look like this:
<?xdoxslt:set_variable($_XDOCTX, Sum1, CS_TCOST + CS_TCOST1)?>
<?xdoxslt:get_variable($_XDOCTX, Sno )?> <?xdoxslt:set_variable($_XDOCTX, Sno, xdoxslt:get_variable($_XDOCTX, Sno) + 1)?>
<?xdofx:if(CS_TSELL + CS_TSELL1) <= 0 then
xdoxslt:set_variable($_XDOCTX, Sum1, 1)
end if?>
I am not sure if you are looking at this or not. Do let me know if this solves the purpose and need be required some help :-o)
HTH,
Nitin -
Need help with calculating interest
Hey im trying to find out where my calculations are screwing up on the interest is coming up wrong but i am unable to find out where. After every month its suppose to be deposit - withdrawl * monthly interest rate and then add that total to the new month etc... any help will be appreciated. Heres my class and test
public class SavingsAccount
private double bal;
private double intRate;
The constructor initializes an object with a
balance and an annual interest rate.
@param bal The account balance.
@param intRate The annual interest rate.
public SavingsAccount(double bal, double intRate)
bal= 0.0;
intRate = 0.0;
The withdraw method withdraws an amount from
the account.
@param amount The amount to withdraw.
public void withdraw(double amount)
bal -= amount;
The deposit method deposits an amount into
the account.
@param amount The amount to deposit.
public void deposit(double amount)
bal += amount;
The addInterest method calculates the monthly
interest and adds it to the account balance.
public void addInterest()
// Get the monthly interest rate.
// Calculate the last amount of interest earned.
// Add the interest to the balance.
intRate = bal * (intRate/12);
bal += intRate;
The getBalance method returns the account balance.
@return The account balance.
public double getBalance()
return bal;
The getInterestRate method returns the annual
interest rate.
@return The annual interest rate.
public double getInterestRate()
return intRate;
The getLastInterest method returns the last amount
of interest earned.
@return The last amount of interest earned.
public double getLastInterest()
return bal;
import java.util.Scanner;
import java.text.DecimalFormat;
public class SavingsAccountTest
public static void main(String args[])
// Annual interest rate
double intRate;
// Starting balance
double startBal;
// Amount of deposits for a month
double deposit;
double totalDeposit;
// Amount withdrawn in a month
double withdrawn;
double totalWithdrawn;
// Interest earned
double intEarned = 0;
// Deposit accumulator
deposit = 0.0;
totalDeposit = 0.0;
// Withdrawal accumulator
withdrawn =0.0;
totalWithdrawn = 0.0;
// Months that have passed
double months;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the starting balance.
System.out.println("What is your account's starting balance");
startBal = keyboard.nextDouble();
while (startBal < 0)
startBal=0;
// Get the annual interest rate.
System.out.println("What is the annual interest rate?");
intRate = keyboard.nextDouble();
while (intRate <= 0 )
intRate = 0;
// Create a SavingsAccount object.
SavingsAccount account = new SavingsAccount(0.0, 0.0);
// Get the number of months that have passed.
System.out.println("How many months have passed since the " +
"account has opened? ");
months = keyboard.nextDouble();
while (months <= 0)
months = 1;
// Get the deposits and withdrawals for each month.
for (int i = 1; i <= months; i++)
// Get the deposits.
System.out.println("Enter the amount deposited during month " + i);
deposit= keyboard.nextDouble();
totalDeposit += deposit;
while (deposit <=0)
deposit = 0;
// Get the withdrawals.
System.out.println("Enter the amount withdrawn during month " + i);
withdrawn = keyboard.nextDouble();
totalWithdrawn += withdrawn;
while (withdrawn <= 0)
withdrawn = 0;
// Add the deposits to the account.
startBal += deposit;
// Subtract the withdrawals.
startBal -= withdrawn;
// Add the monthly interest.
intRate = startBal * intRate/12;
startBal += intRate;
// Accumulate the amount of interest earned.
intRate += intEarned;
// Create a DecimalFormat object for formatting output.
DecimalFormat dollar = new DecimalFormat("#,##0.00");
// Display the totals and the balance.
System.out.println("Total deposited: " + dollar.format(totalDeposit));
System.out.println("Total withdrawn: " + dollar.format(totalWithdrawn));
System.out.println("Total interest earned: " + dollar.format(intEarned));
System.out.println("Account balance: " + dollar.format(startBal));
}Ok this is what i have fixed up so far but im still having trouble calculating the interest. Problem1) We were given the skeleton to the class and demo. I cannot figure out what to enter in getLastInterest.(completely lost all i need is hint) 2)When i try to get the Total money deposited and i call the account.deposit(balance) it keeps on giving an error void not allowed. Any help is appreciated
public class SavingsAccount
private double balance;
private double interest;
private double intEarned;
The constructor initializes an object with a
balance and an annual interest rate.
@param bal The account balance.
@param intRate The annual interest rate.
public SavingsAccount(double bal, double intRate)
balance = bal;
interest = intRate;
The withdraw method withdraws an amount from
the account.
@param amount The amount to withdraw.
public void withdraw(double amount)
balance -= amount;
The deposit method deposits an amount into
the account.
@param amount The amount to deposit.
public void deposit(double amount)
balance += amount;
The addInterest method calculates the monthly
interest and adds it to the account balance.
public void addInterest()
// Get the monthly interest rate.
// Calculate the last amount of interest earned.
// Add the interest to the balance.
interest = balance * (interest/12);
interest = intEarned;
balance += interest;
The getBalance method returns the account balance.
@return The account balance.
public double getBalance()
return balance;
The getInterestRate method returns the annual
interest rate.
@return The annual interest rate.
public double getInterestRate()
return interest;
The getLastInterest method returns the last amount
of interest earned.
@return The last amount of interest earned.
public double getLastInterest()
return intEarned;
import java.util.Scanner;
import java.text.DecimalFormat;
public class SavingsAccountTest
public static void main(String args[])
// Annual interest rate
double intRate;
// Starting balance
double balance;
// Amount of deposits for a month
double deposit;
// Amount withdrawn in a month
double withdraw;
// Interest earned
double intEarned = 0;
// Deposit accumulator
deposit = 0.0;
// Withdrawal accumulator
withdraw =0.0;
// Months that have passed
double months;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the starting balance.
System.out.println("What is your account's starting balance");
balance = keyboard.nextDouble();
if (balance < 0)
balance=0;
// Get the annual interest rate.
System.out.println("What is the annual interest rate?");
intRate = keyboard.nextDouble();
if (intRate <= 0 )
intRate = 0;
// Create a SavingsAccount object. Cannot find Symbol!!
SavingsAccount account = new SavingsAccount(balance,intRate);
// Get the number of months that have passed.
System.out.println("How many months have passed since the " +
"account has opened? ");
months = keyboard.nextDouble();
if (months <= 0)
months = 1;
// Get the deposits and withdrawals for each month.
for (int i = 1; i <= months; i++)
// Get the deposits.
System.out.println("Enter the amount deposited during month " + i);
deposit= keyboard.nextDouble();
account.deposit(deposit);
if (deposit <=0)
deposit = 0;
// Get the withdrawals.
System.out.println("Enter the amount withdrawn during month " + i);
withdraw = keyboard.nextDouble();
account.withdraw(withdraw);
if (withdraw <= 0 || withdraw >= balance)
withdraw = 0;
// Add the deposits to the account.
account.deposit(balance);
// Subtract the withdrawals.
account.withdraw(balance);
// Add the monthly interest.
account.addInterest();
// Accumulate the amount of interest earned. ????? Wrong
intRate += intEarned;
// Create a DecimalFormat object for formatting output.
DecimalFormat dollar = new DecimalFormat("#,##0.00");
// Display the totals and the balance.
System.out.println("Total deposited: " + dollar.format(account.deposit(balance)));
System.out.println("Total withdrawn: " + dollar.format(account.withdraw(balance)));
System.out.println("Total interest earned: " + dollar.format(account.addInterest()));
System.out.println("Account balance: " + dollar.format(account.getBalance()));
} -
Need help in calculating a total from flowable table
I've tried everything to include using the example from the tutorial on creating a flowable purchase order form. My problem is that I can't get the total field to reflect a total. I'd be willing to send the form to anyone willing to shed some light and provide a solution.
ThanksPaul, I don't believe that I'm grasping exactly what you are saying. I have several forms at work that I've designed (none with flowable content however) with calculations, it's just I can't seem to get this one to do what I need. So.... let me plead ignorance on this one for the moment.
Actually, I have the one row that accepts data, then if the user wants to, they can click on the add item button to add another instance. Even after entering the one rows data, that amount does not reflect in the total field. You would likely need to see the form possibly, and if so, let me know. I'd be glad to have your help in any way you could provide it.
Mike -
Need help with calculator project for an assignment...
Hi all, I please need help with my calculator project that I have to do for an assignment.
Here is the project's specifications that I need to do"
"""Create a console calculator applicaion that:
* Takes one command line argument: your name and surname. When the
program starts, display the date and time with a welcome message for the
user.
* Display all the available options to the user. Your calculator must include
the arithmetic operations as well as at least five scientific operations of the
Math class.
-Your program must also have the ability to round a number and
truncate it.
-When you multiply by 2, you should not use the '*' operator to perform the
operation.
-Your program must also be able to reverse the sign of a number.
* Include sufficient error checking in your program to ensure that the user
only enters valid input. Make use of the String; Character, and other
wrapper classes to help you.
* Your program must be able to do conversions between decimal, octal and
hex numbers.
* Make use of a menu. You should give the user the option to end the
program when entering a certain option.
* When the program exits, display a message for the user, stating the
current time, and calculate and display how long the user used your
program.
* Make use of helper classes where possible.
* Use the SDK to run your program."""
When the program starts, it asks the user for his/her name and surname. I got the program to ask the user again and again for his/her name and surname
when he/she doesn't insert anything or just press 'enter', but if the user enters a number for the name and surname part, the program continues.
Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??
Here is the programs code that I've written so far:
{code}
import java.io.*;
import java.util.*;
import java.text.*;
public class Project {
private static String nameSurname = "";
private static String num1 = null;
private static String num2 = null;
private static String choice1 = null;
private static double answer = 0;
private static String more;
public double Add() {
answer = (Double.parseDouble(num1) + Double.parseDouble(num2));
return answer;
public double Subtract() {
answer = (Double.parseDouble(num1) - Double.parseDouble(num2));
return answer;
public double Multiply() {
answer = (Double.parseDouble(num1) * Double.parseDouble(num2));
return answer;
public double Divide() {
answer = (Double.parseDouble(num1) / Double.parseDouble(num2));
return answer;
public double Modulus() {
answer = (Double.parseDouble(num1) % Double.parseDouble(num2));
return answer;
public double maximumValue() {
answer = (Math.max(Double.parseDouble(num1), Double.parseDouble(num2)));
return answer;
public double minimumValue() {
answer = (Math.min(Double.parseDouble(num1), Double.parseDouble(num2)));
return answer;
public double absoluteNumber1() {
answer = (Math.abs(Double.parseDouble(num1)));
return answer;
public double absoluteNumber2() {
answer = (Math.abs(Double.parseDouble(num2)));
return answer;
public double Squareroot1() {
answer = (Math.sqrt(Double.parseDouble(num1)));
return answer;
public double Squareroot2() {
answer = (Math.sqrt(Double.parseDouble(num2)));
return answer;
public static String octalEquivalent1() {
int iNum1 = Integer.parseInt(num1);
String octal1 = Integer.toOctalString(iNum1);
return octal1;
public static String octalEquivalent2() {
int iNum2 = Integer.parseInt(num2);
String octal2 = Integer.toOctalString(iNum2);
return octal2;
public static String hexadecimalEquivalent1() {
int iNum1 = Integer.parseInt(num1);
String hex1 = Integer.toHexString(iNum1);
return hex1;
public static String hexadecimalEquivalent2() {
int iNum2 = Integer.parseInt(num2);
String hex2 = Integer.toHexString(iNum2);
return hex2;
public double Round1() {
answer = Math.round(Double.parseDouble(num1));
return answer;
public double Round2() {
answer = Math.round(Double.parseDouble(num2));
return answer;
SimpleDateFormat format1 = new SimpleDateFormat("EEEE, dd MMMM yyyy");
Date now = new Date();
SimpleDateFormat format2 = new SimpleDateFormat("hh:mm a");
static Date timeIn = new Date();
public static long programRuntime() {
Date timeInD = timeIn;
long timeOutD = System.currentTimeMillis();
long msec = timeOutD - timeInD.getTime();
float timeHours = msec / 1000;
return (long) timeHours;
DecimalFormat decimals = new DecimalFormat("#0.00");
public String insertNameAndSurname() throws IOException{
boolean inputCorrect = false;
while (inputCorrect == false) {
while (nameSurname == null || nameSurname.length() == 0) {
for (int i = 0; i < nameSurname.length(); i++) {
if ((nameSurname.charAt(i) > 'a') && (nameSurname.charAt(i) < 'Z')){
inputCorrect = true;
else{
inputCorrect = false;
break;
try {
BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
System.out.print("Please enter your name and surname: ");
nameSurname = inStream.readLine();
inputCorrect = true;
}catch (IOException ex) {
System.out.println("You did not enter your name and surname, " + nameSurname + " is not a name, please enter your name and surname :");
inputCorrect = false;
System.out.println("\nA warm welcome " + nameSurname + " ,todays date is: " + format1.format(now));
System.out.println("and the time is now exactly " + format2.format(timeIn) + ".");
return nameSurname;
public String inputNumber1() throws IOException {
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
System.out.print("\nPlease enter a number you want to do a calculation with and hit <ENTER>: ");
num1 = br.readLine();
double number1 = Double.parseDouble(num1);
System.out.println("\nThe number you have entered is: " + number1);
inputCorrect = true;
} catch (NumberFormatException nfe) {
System.out.println("\nYou did not enter a valid number: " + "\""+ num1 + "\" is not a number!!");
inputCorrect = false;
return num1;
public String calculatorChoice() throws IOException {
System.out.println("Please select an option of what you would like to do with this number from the menu below and hit <ENTER>: ");
System.out.println("\n*********************************************");
System.out.println("---------------------------------------------");
System.out.println("Please select an option from the list below: ");
System.out.println("---------------------------------------------");
System.out.println("1 - Add");
System.out.println("2 - Subtract");
System.out.println("3 - Multiply");
System.out.println("4 - Divide (remainder included)");
System.out.println("5 - Maximum and minimum value of two numbers");
System.out.println("6 - Squareroot");
System.out.println("7 - Absolute value of numbers");
System.out.println("8 - Octal and Hexadecimal equivalent of numbers");
System.out.println("9 - Round numbers");
System.out.println("0 - Exit program");
System.out.println("**********************************************");
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
System.out.print("Please enter your option and hit <ENTER>: ");
choice1 = inStream.readLine();
int c1 = Integer.parseInt(choice1);
System.out.println("\nYou have entered choice number: " + c1);
inputCorrect = true;
} catch (NumberFormatException nfe) {
System.out.println("You did not enter a valid choice number: " + "\""+ choice1 + "\" is not in the list!!");
inputCorrect = false;
return choice1;
public String inputNumber2() throws IOException {
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader br2 = new BufferedReader (new InputStreamReader(System.in));
System.out.print("\nPlease enter another number you want to do the calculation with and hit <ENTER>: ");
num2 = br2.readLine();
double n2 = Double.parseDouble(num2);
System.out.println("\nThe second number you have entered is: " + n2);
System.out.println("\nYour numbers are: " + num1 + " and " + num2);
inputCorrect = true;
} catch (NumberFormatException nfe) {
System.out.println("You did not enter a valid number: " + "\""+ num2 + "\" is not a number!!");
inputCorrect = false;
return num2;
public int Calculator() {
int choice2 = (int) Double.parseDouble(choice1);
switch (choice2) {
case 1 :
Add();
System.out.print("The answer of " + num1 + " + " + num2 + " is: " + decimals.format(answer));
break;
case 2 :
Subtract();
System.out.print("The answer of " + num1 + " - " + num2 + " is: " + decimals.format(answer));
break;
case 3 :
Multiply();
System.out.print("The answer of " + num1 + " * " + num2 + " is: " + decimals.format(answer));
break;
case 4 :
Divide();
System.out.print("The answer of " + num1 + " / " + num2 + " is: " + decimals.format(answer));
Modulus();
System.out.print(" and the remainder is " + decimals.format(answer));
break;
case 5 :
maximumValue();
System.out.println("The maximum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
minimumValue();
System.out.println("The minimum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
break;
case 6 :
Squareroot1();
System.out.println("The squareroot of value " + num1 + " is: " + decimals.format(answer));
Squareroot2();
System.out.println("The squareroot of value " + num2 + " is: " + decimals.format(answer));
break;
case 7 :
absoluteNumber1();
System.out.println("The absolute number of " + num1 + " is: " + decimals.format(answer));
absoluteNumber2();
System.out.println("The absolute number of " + num2 + " is: " + decimals.format(answer));
break;
case 8 :
octalEquivalent1();
System.out.println("The octal equivalent of " + num1 + " is: " + octalEquivalent1());
octalEquivalent2();
System.out.println("The octal equivalent of " + num2 + " is: " + octalEquivalent2());
hexadecimalEquivalent1();
System.out.println("\nThe hexadecimal equivalent of " + num1 + " is: " + hexadecimalEquivalent1());
hexadecimalEquivalent2();
System.out.println("The hexadecimal equivalent of " + num2 + " is: " + hexadecimalEquivalent2());
break;
case 9 :
Round1();
System.out.println("The rounded number of " + num1 + " is: " + decimals.format(answer));
Round2();
System.out.println("The rounded number of " + num2 + " is: " + decimals.format(answer));
break;
case 0 :
if (choice2 == 0) {
System.exit(1);
break;
return choice2;
public String anotherCalculation() throws IOException {
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader br3 = new BufferedReader (new InputStreamReader(System.in));
System.out.print("\nWould you like to do another calculation? Y/N ");
more = br3.readLine();
String s1 = "y";
String s2 = "Y";
if (more.equals(s1) || more.equals(s2)) {
inputCorrect = true;
while (inputCorrect = true){
inputNumber1();
System.out.println("");
calculatorChoice();
System.out.println("");
inputNumber2();
System.out.println("");
Calculator();
System.out.println("");
anotherCalculation();
System.out.println("");
inputCorrect = true;
} else {
System.out.println("\n" + nameSurname + " thank you for using this program, you have used this program for: " + decimals.format(programRuntime()) + " seconds");
System.out.println("the program will now exit, Goodbye.");
System.exit(0);
} catch (IOException ex){
System.out.println("You did not enter a valid answer: " + "\""+ more + "\" is not in the list!!");
inputCorrect = false;
return more;
public static void main(String[] args) throws IOException {
Project p1 = new Project();
p1.insertNameAndSurname();
System.out.println("");
p1.inputNumber1();
System.out.println("");
p1.calculatorChoice();
System.out.println("");
p1.inputNumber2();
System.out.println("");
p1.Calculator();
System.out.println("");
p1.anotherCalculation();
System.out.println("");
{code}
*Can you please run my code for yourself and have a look at how this program is constructed*
*and give me ANY feedback on how I can better this code(program) or if I've done anything wrong from your point of view.*
Your help will be much appreciated.
Thanks in advanceSmirre wrote:
Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??You cannot restrict the user. It is a sad fact in programming that the worst bug always sits in front of the Computer.
What you could do is checking the input string for numbers. If it contains numbers, just reprompt for the Name.
AND you might want to ask yourself why the heck a calculator needs to know the users Name. -
Need Help in Calculation of Paid and Unpaid Break in Daily Work Schedule
hai,
I am a student of SAP-HCM. I am having problem with the calculation
in Paid and Unpaid Break in Daily work schedule (Time Management).
Please help.
thank you
Dev.Hi,
The above screen shot is table where we maintain unpaid and paid breaks, we mention about when a break has to start under START tab and when it has to end under END button.
Under UNPAID and PAID tabs we mention duration of break, if its 15 mins break or half an hour or one hour depending on start and end timings.
Suppose a shift is for 9 hours in total and client wants there should be a paid break of one hour, then out of this 9 hours shift itself break would be considered.... and in case client wants unpaid break then shift would be for 10 hours out of which 9 hours will be working hours and one hour break.
When this concept has to be calculated in schema processing type would be assigned to this time pair showing break accordingly either paid or unpaid. -
Need help with calculated fields in Adobe Interactive Forms
Hi Gurus,
I have an Adobe Interactive form in which i have radio buttons. Upon selecting any of the radio buttons, value in text box should be changed( Calculqated filedS). How i can achieve this?
Regards,
Srini
Moderator message: wrong forum, please post again in Adobe Interactive Forms, but always try yourself before asking.
Edited by: Thomas Zloch on Jul 13, 2010 11:58 AMHi Tapan
No, it's working ,with one remark.
I've done a mistake, in the final formula. The logic remain the same! ;)
The calculation values for second column ( COL2 ) are 1,2,3 and not 0,1,2 as I wrote before and as for COL1 are so the formula is
=3*if(COL1="ABC",0,IF(COL1="DEF",1,2)+if(COL2="RST",1,IF(COL2="YYZ",2,3)
and not
=3*if(COL1="ABC",0,IF(COL1="DEF",1,2)+if(COL2="RST",0,IF(COL2="YYZ",1,2)
I created also a real example for you, with 2 dif calculation ways . First I created 2 calc_columns for COL1 and COL2 ( CALC_COL1+CALC_COL and after I added both these 2 column , and second way is to calculate directly) .
Check this image
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you. -
Need Urgent Help on Calculation items issue In Discoverer Plus
Dear Discoverer Experts,
I would need help on the below scenario:
A
147644.08
147644.08
Maximum: 147,644.08
B
142494.65
5149.43
Sum: 147,644.08
C
5149.43
142494.65
0
Here A, B, C are columns and C column is Calculated Item(A-B) and Maximum and Sum are Totals items, everything working fine.
The intent is that I would need the difference between totals items I mean Maximum and Sum , i.e Maximum-Sum (147,644.08 - 147,644.08) =0(in this case), but I am not able to get it, can anyone help me on this that would be greatly appreciated.
Thanks
skatThanks Tamir for your response, i am getting ZERO
But when i create new calculation item for examle TEST with calculation MAX(A) over () - SUM(B) over ()
then i am getting new column next to C with name TEST and with two rows of data with 0 (Zero)
like this
TEST
0.00
0.00
why am getting two rows of data, and that too can't we get this ZERO under C column at the same Row as MAX and SUM
(Or)
if not possible then after adding coumn TEST next to C column can we get ZERO in the row as MAX and SUM
either way would be fine, can any one hlep on this issue.
Thank you
skat -
Help With LightRoom Aspect Ratio Settings
I have created some custom Aspect Ratio settings to the crop tool but I now want to delete them as I entered them wrong.
Can anyone tel me how I can delete the custom ones I have made or reset back to defaults.
I am guessing they are written out to a file somewhere.
IanHi
Many thanks for all your help. (very useful information)
This is now fixed and although it did not affect the useage, it did bother me
Regards
Ian -
Need help on Calculation Logic in Bex
Dear BW Experts,
I am working on Reporting. I have a requirement in my report.
Output of the Report :
State_________Material_____Total_Closed_Calls____No of Part Consumed
Karnataka_____Cell Charger__10_________________2
_____________Battery_______20________________4
_____________Pin___________25_______________5
Result____________________55________________11
Mumbai______Keypad________20_______________8
____________Cover_________10________________5
Result____________________30________________13
I want to calculate % of part Consumed.
ie)(No of Part Consumed /Total Number of Closed Calls) * 100
In the case of Karnataka, (2 / 55)*100 = 3.6
State_______Material_____Total_Closed_Calls____No of Part Consumed____% of Consume
Karnataka___Cell Charger__10____________________2_____________________3.6
___________Battery_______20___________________4_____________________7.2
___________Pin___________25__________________5_____________________9.0
Result____________________55__________________11
Mumbai______Keypad________20_________________8_____________________26.6
____________Cover_________10_________________5_____________________20
Result____________________30__________________13
How can i achieve this calculation in Bex.
Please help on this issue.
Thanks,
Siva.
Edited by: Siva Kumar on Jun 29, 2009 11:49 AMCreate a formula as follows...
'No of parts consumed' %CT 'Total number of calls closed'.
I have also observed that you dont want that calculation for total. I saw that blank in your example.
If that is the case, then go to "Calculation" tab and select calculate resutl as "HIDE". That should hide your result value for this particular formula.
- Danny -
Please Help/ GUI Calculator
I'm trying to create a GUI Calculator but cannot get my program to compile. Please could someone assistm, thanks.
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalculatorFrame extends JFrame
private Container contentPane;
//The componenets used in the calculator
private JTextField display;
private JButton addition;
private JButton subtract;
private JButton multiply;
private JButton divide;
private JButton mod;
private JButton enter;
private JButton [] digits;
//End of components
//Integer representations for the arithmetic operations needed
private final static int ADD = 1;
private final static int SUB = 2;
private final static int MUL = 3;
private final static int DIV = 4;
private final static int MOD = 5;
//ENd of arithmethic operations
//Integer holding the operator that the user requested
private int op;
//Boolean variable to help perform the calculations
private boolean firstFilled;
private boolean clearScreen;
//Constructor for the class
public CalculatorFrame()
contentPane=new Container();
this.setSize(400,300); //sets the size of the frame
this.setTitle("MIS 222 Calculator"); //sets the title of the frame
//allows the "X" box in the upper right hand corner to close the entire application
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane=this.getContentPane(); //gets the content pane
//Methods
addDisplay();
addDigits();
addDigitActionListeners();
addOperation();
private void addDisplay()
JLabel displayLab = new JLabel("Answer");
JPanel north = new JPanel();
north.add(displayLab);
contentPane.add(north, "North");
//diplay was already declared above the constructor
display = new JTextField(25);
//adding the components to the panel
north.add(displayLab);
north.add(display);
//adding the panel to frame's content pane
contentPane.add(north, "North");
//Declaring the global digits array
private void addDigits()
//Add 1 large panel to hold the 3 inner panels
JPanel digPanel = new JPanel();
//Set the panel's preferred size so that it will keep everything in line
digPanel.setPreferredSize(new Dimension(200, 275));
//Initialize the top 3 digits' JPanel and set its preferrd size
JPanel topDigits = new JPanel();
topDigits.setPreferredSize(new Dimension(200,60));
//Initialize the middle 2 digits' JPanel and set its preferred size
JPanel midDigits = new JPanel();
midDigits.setPreferredSize(new Dimension(200,60));
//Initialize the bottom digits' JPanel and set its preferred size
JPanel botDigits = new JPanel();
botDigits.setPreferredSize(new Dimension(200, 75));
//Initialize the JButton array
digits = new JButton[11];
//Initialize each of the top Panel's digit buttons, and add it to the top panel
for(int i=1; i<4; i++)
String lab=(new Integer(i)).toString();
digits=new JButton(lab);
topDigits.add(digits[i]);
//Adding the top Digit Panel to the overall digit panel
digPanel.add(topDigits, BorderLayout.CENTER);
//Adding the middle Digit Panel to the overall digit panel
digPanel.add(midDigits, BorderLayout.CENTER);
//Adding the bottom Digit Panel to the overall digit panel
digPanel.add(botDigits, BorderLayout.CENTER);
//Add the overall digit Panel to the Frame's contentpane
contentPane.add(digPanel, BorderLayout.CENTER);
//Method created to add the DigitAction Listeners
addDigitActionListeners();
//Method created to add all of the DigitActionListeners
private void addDigitActionListeners()
for(int i=0; i<10; i++)
digits[i].addActionListener(new DigitActionListener(i));
digits[10].addActionListener(new DigitActionListener("."));
//DigitActionListener class
public class DigitActionListener implements ActionListener
private String myNum;
public DigitActionListener(int num)
myNum=""+num;
public DigitActionListener(String num)
myNum=num;
public void actionPerformed(ActionEvent e)
if(display.getText().equals("Please enter a valid number")|| clearScreen)
clearScreen=false;
display.setText("");
//OperatorActionListener class
public void OpActionListener implements ActionListener
private int myOpNum;
public OpActionListener(int op)
myOpNum=op;
public void actionPerformed(ActionEvent e)
{ //Checks to see if the user has already enterd a number
if(!firstFilled)
try{
//Parse the number entered
String number=display.getText();
dNum1=Double.parseDouble(number);
//Sets the flag for the firstFilled to true
firstFilled=true
//Sets the op variable so when the "Enter" button is pressed, it will know which operation to perform
op=myOpNum;
//Clears the textbox
display.setText("");
catch(Exception er)
display.setText("Please enter a valid number");
//This is the second number being entered
else{
try{
String number=display.getText();
String result;
dNum2=Double.parseDouble(number);
firstFilled=true;
op=myOpNum;
display.setText("");
catch(Exception er)
display.setText("Please enter a valid number");
private void addOperation()
JPanel opPanel=new JPanel();
opPanel.setPreferredSize(new Dimension(75,200));
JButton clear = new JButton("C");
JButton addition = new JButton("+");
JButton subtraction = new JButton("-");
JButton multiply = new JButton("*");
JButton divide = new JButton("/");
JButton mod = new JButton("%");
JButton enter = new JButton("Enter");
addition.addActionListener(new OpActionListener(ADD));
subtraction.addActionListener(new OpActionListener(SUB));
multiply.addActionListener(new OpActionListener(MUL));
divide.addActionListener(new OpActionListener(DIV));
mod.addActionListener(new OpActionListener(MOD));
clear.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
display.setText("");
firstFilled=false;
enter.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
double result;
String answer="";
String number = display.getText();
dNum2 = Double.parseDouble(number);
dNum1=Double.parseDouble(number);
switch(op)
case ADD:
result = dNum1 + dNum2;
break;
case SUB:
result = dNum1 - dNum2;
break;
case MUL:
result = dNum1 * dNum2;
break;
case DIV:
result = dNum1 / dNum2;
break;
default:
result= -1.0;
break;
if(result==(int)result)
answer=(new Integer((int)result)).toString();
else
answer=(new Double(result)).toString();
display.setText(answer);
clearScreen=true;
firstFilled=false;
dNum1=0;
dNum2=0;
opPanel.add(clear);
opPanel.add(addition);
opPanel.add(subtraction);
opPanel.add(multiply);
opPanel.add(divide);
opPanel.add(mod);
opPanel.add(enter);
contentPane.add(opPanel, "East");
//Creating the frame object
public class CalculatorMain
public void main(String[] args)
CalculatorFrame cf=new CalculatorFrame();
cf.show();
ERRORS THAT I HAVE!!:
javac calculatorframe.javacalculatorframe.java:150: '(' expected
public void OpActionListener implements ActionListener
^
calculatorframe.java:7: class CalculatorFrame is public, should be declared in a file named CalculatorFrame.java
public class CalculatorFrame extends JFrame
^
calculatorframe.java:54: cannot resolve symbol
symbol : method addOperation ()
location: class CalculatorFrame
addOperation();
^
3 errors
>Hi, actually it's all written there:
>
ERRORS THAT I HAVE!!:
javac calculatorframe.javacalculatorframe.java:150: '(' expected
public void OpActionListener implements
ActionListenerpublic void ... is part of a possible method signature. That's probably why the compiler expects '(' as this is need for a method.
To define a class use:
public class ... (or better: private class ..., if the class is not used outside of this file.
^
calculatorframe.java:7: class CalculatorFrame is
public, should be declared in a file named
CalculatorFrame.java
public class CalculatorFrame extends JFrame
^As it says, you defined a class CalculatorFrame in a file calculatorframe.java. But the file name should be the same as the class name (case sensitive). Java classes should start with capital letters, so rename the file to:
CalculatorFrame.java
calculatorframe.java:54: cannot resolve symbol
symbol : method addOperation ()
location: class CalculatorFrame
addOperation();
^
3 errors
>You didn't declare the method 'addOperation' (-> cannot resolve symbol; which simbol: method addOperation (); where: location: class CalculatorFrame; you see it's all there)
Note there is a method called 'addOperation' in the class OpActionListener, but not in CalculatorFrame.
Note I didn't read the code, just the error messages. I hope this helps.
-Puce -
Help with setting aspect ratio
Could someone please help me with an aspect ratio problem. I have just updated to iMovie 6 and want to work with an existing movie project created from iMovie (version before the ilife 5 version). On opening the project in the new version it is in widescreen and I would like to convert back to a regular format (regular display format) I would be most grateful for any help
ThankyouWell, I guess I thought the video in Motion needed to look more rectangle (16x9) than square (4:3). Since it did in FCP. And my FCP sequence setting>Aspect Ratio says NTSC DV 3:2
I am used to working with plain MiniDV 4:3. I shoot with Sony PD150. I don't understand or never had to deal with Aspect Ratios. This project they wanted a widescreen look so I switch the camera to 16x9.
I don't think it is the real 16x9 but like I said I don't know about this stuff or why my camera has 16x9 on in if it is not the real thing.
Feel free to comment, I am trying to learn -
I'm a newbie to SSAS and am having trouble creating a calculated member. My goal is to calculate the number of requests based on status in a specific month/year, however I'd like to enable users to show all amounts on a single report.
An excerpt of my cube is as follows:
FACT REQUESTS
Measures.Request Count
DIM STATUS
Status Description (i.e. Active/Inactive)
I'd like to create calculated members that will produce the following type of report:
Month Year Total Active Total Inactive
Jan 2013 10 20
Feb 2013 10 25
I previously processed the following code:
CREATE MEMBER CURRENTCUBE.[Measures].[Total Active Requests]
AS NULL, VISIBLE = 1;
Scope [Measures].[Total Active Requests];
Scope [DIM STATUS].[Status Description].[ACTIVE];
THIS = SUM ([Measures].[Request Count]);
END SCOPE;
END SCOPE;
CREATE MEMBER CURRENTCUBE.[Measures].[Total Inactive Requests]
AS NULL, VISIBLE = 1;
Scope [Measures].[Total Closed Requests];
Scope [DIM STATUS].[Status Description].[INACTIVE];
THIS = SUM ([Measures].[Request Count]);
END SCOPE;
END SCOPE;
However when pulling the values over to the report, the users were unable to see both Active and Inactive at the same time (so I'm guessing Scope isn't the best approach). Is there another method I can follow? I appreciate any help you can offer.
Thanks!!no need for a scope statement, try the following with 2 different calc measures.
IIF(ISERROR([DIM STATUS].[Status Description].&[ACTIVE]), NULL,([DIM
STATUS].[Status Description].&[ACTIVE],[Measures].[Request Count]))
IIF(ISERROR([DIM STATUS].[Status Description].&[INACTIVE]),
NULL,([DIM STATUS].[Status Description].&[INACTIVE],[Measures].[Request
Count]))
you can ignore the iif statement, thats just for error handling.
Maybe you are looking for
-
My BB CUrve 9320 are not support Blackberry Map(GPS)
Why I can't open Blackberry Map(GPS) in my BB Curve 9320?
-
How does Website Storage Settings Panel work?
I was trying to play a game on facebook and was having trouble. Facebook gave me the link here to the Website Storage Settings Panel and told me to delete all sites. When I get the page the website storage settings panel is flickering. I never see a
-
HP loadrunner report for database performance
Hi Team, client testing team gave us a report for database, from load runner and asked if the database load testing parameters is correct on the basis of below mentioned 4 parameters. I have also attached report here for your reference. please help m
-
In the olden days, like AS-400 era we have Initiators (The Thread) and also in the Job Control Language we can assign the Priority of that particular job, high or medium or low and that will assign the appropriate que and it will be processed. But in
-
Hi Experts, Request for your assistance. Currently the tax for kansas city, MO (MO01 tax code) is being calculated on 1 % of taxable wages (/701) = /701 X 1% But the calculation should happen by adding wage type /Q01 too. i.e /701 + /Q01 X 1% How ca