Finding maximum value???
import java.io.*;
import java.util.*;
public class heatshield1
public static void main(String [] args) throws IOException
double theresholdTemp = 0, percentPass = 0;
int maxOfSample = 0;
String inputdata;
String s1,s2,s3;
InputStreamReader isr = new InputStreamReader (System.in);
FileReader file = new FileReader("inputdata.txt");
BufferedReader br = new BufferedReader(file);
inputdata = br.readLine();
StringTokenizer st = new StringTokenizer(inputdata);
s1 = st.nextToken();
s2 = st.nextToken();
s3 = st.nextToken();
theresholdTemp = Double.parseDouble(s1);
percentPass = Double.parseDouble(s2);
maxOfSample = Integer.parseInt(s3);
if (theresholdTemp <= 0 || percentPass< 0 || maxOfSample <= 0)
System.out.println("Program Halted and Error occured at Line 1");
System.exit(0);
sample_Input(br,theresholdTemp,percentPass,maxOfSample);
public static void sample_Input(BufferedReader br,double theresholdTemp,double percentFail,int maxOfSample) throws IOException
int totalOfPass = 0;
double temp[];
temp = new double[maxOfSample];
for ( int k=0; k < maxOfSample ; k++)
temp[k] =maxOfTemp(br);
if (temp[k] > theresholdTemp)
System.out.println("Sample "+(k+1)+" "+temp[k]+" passed");
totalOfPass = totalOfPass + 1;
else
System.out.println("Sample "+(k+1)+" "+temp[k]+" failed");
displayResult(totalOfPass,maxOfSample,percentFail);
public static double maxOfTemp(BufferedReader br) throws IOException
String inputdata;
inputdata = br.readLine();
StringTokenizer st = new StringTokenizer(inputdata);
int noOfreading = st.countTokens();
String s4;
double InputTemp[];
InputTemp = new double[noOfreading];
double maxOfTemp = 0;
maxOfTemp = InputTemp[0];
try
for ( int j =0; j < InputTemp.length ; j++)
if (maxOfTemp< InputTemp[j])
maxOfTemp = InputTemp[j];
s4 = st.nextToken();
InputTemp[j] = Double.parseDouble(s4);
if (InputTemp[j] < 0)
System.out.println("Program Halted and Error occured at Line "+(j+2));
System.exit(0);
catch (NumberFormatException n)
System.out.println("You must enter a number.");
System.exit(0);
finally
return maxOfTemp;
public static void displayResult(int totalOfPass,int maxOfSample,double percentPass)
double percentOfPass = 0;
percentOfPass = (((double)totalOfPass/(double)maxOfSample)*100);
if (percentOfPass > percentPass)
System.out.println("BATCHES Pass");
else
System.out.println("BATCHES Failure");
Te objective of this program to find the maximum value of the input data and use it compare to the threshold temperature.
There is no error when compiling but the program can detect the maximum value for the input data. Is it anything wrong with the code i used to find the maximum. Please help.
Thanks for ur addition information
but after i compling it using ur guideline
The result appear to be
start maxOfTemp=0.0 array size=3
j=0 InputTemp[j]=0.0
j=1 InputTemp[j]=0.0
j=2 InputTemp[j]=0.0
Sample 1 13.0 passed
start maxOfTemp=0.0 array size=3
j=0 InputTemp[j]=0.0
j=1 InputTemp[j]=0.0
j=2 InputTemp[j]=0.0
Sample 2 14.0 passed
start maxOfTemp=0.0 array size=4
j=0 InputTemp[j]=0.0
j=1 InputTemp[j]=0.0
j=2 InputTemp[j]=0.0
j=3 InputTemp[j]=0.0
Sample 3 70.0 failed
BATCHES Pass
There are no value for the maxOfTemp
and and the value fo InputTemp..
How to solve it ??
Similar Messages
-
How can I force the Data Finder to index/calculate certain properties (like Maximum Value) so I can execute a query on this.
I would like to do this automatically for every channel, or should I run some script to get this?
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!Thanks Brad,
I decided to keep ascii format for now because tdm file has double size. I would like to ask you if there is the possibility to generate TDM-files from ascii-files and save them in another place by using dataplugin VBscript. So I need to launch from diadem dataplugin a script like this:
Sub ReadStore(File)
Set ChannelGroup = Root.ChannelGroups.Add("test")
Call ASCIIConfigLoad(file, "pluginname", 0)
Call DataFileSave("C:\file.tdm","TDM")
end sub
I know that it's no possibile to use diadem commands in dataplugin. Are there some alternative solutions?
I tryed to create vbscript dataplugin that for every ascii file indexed writes a file path to access mdb database and by diadem macro loads ascii file from mbd_file and saves it in another folder. I don't think that is the best solution. Is very long.
Thanks,
Yustas -
Finding maximum value from VARCHAR2
Hi all.
I am having Varchar2 values like this....
1.0.0.22
1.0.0.23
1.0.0.3
1.0.0.6
1.0.0.7
1.0.0.8
1.0.0.9
1.0.0.9
I want to find the highest value (in this case, it is 1.0.0.23). If i use MAX function, it is giving 1.0.0.9. Any help is appreciated.
Thanks in advance,
PalIn 10g, I would use regular expressions to "format" those version numbers. In my example, it would work for 3-digit version numbers, regardles on which position:
WITH t AS (SELECT '1.0.0.22' col1
FROM dual
UNION
SELECT '1.0.0.23'
FROM dual
UNION
SELECT '1.0.0.3'
FROM dual
UNION
SELECT '1.0.0.6'
FROM dual
UNION
SELECT '1.0.0.7'
FROM dual
UNION
SELECT '1.0.0.8'
FROM dual
UNION
SELECT '1.0.0.9'
FROM dual
SELECT col1
FROM (SELECT t.*
, ROW_NUMBER() OVER (ORDER BY REGEXP_REPLACE(REGEXP_REPLACE(t.col1,
'([0-9]+)(\.|$)',
'000\1\2'),
'([0-9]{3}(\.|$))|.',
'\1') DESC
) rn
FROM t
WHERE rn = 1
; C. -
How to find out the maximum value of one array
hi all..
I have one array that consists of some elements
so I want the maximum value of the list ...
if anyone knows this please help me..
thanks..>
If your array is already sorted, you can do a binary
search.
I think there are already methods to do that in
java.util.Arrays. (?)
If not, it's not hard to find an example on the net.
A binary search will be more efficient.1. If your array is already sorted, you do not need a binary search. Either check the value of arr[0] or arr[arr.length - 1] depending on the direction of sorting.
2. If your array is not sorted, try this:
int maxValue = arr[0];
for(int index = 1; index < arr.length; index++)
if(arr[index] > maxValue)
maxValue = arr[index];
} -
How to find out the maximum value in a Query
Dear all,
Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material..
EX:
MATERIAL BILLED VALUE
x 1000
y 3000
z 2500
in a analyser i have to display only Y and 3000
We are using BW 7.0 version
Can any one help me out in this
Thxs in Advance
VenuHi Venu,
You may wish to refer the link below:
http://help.sap.com/saphelp_nw04/helpdata/en/17/82853c2dc5c505e10000000a11405a/content.htm
Assign points if this is helpful.
Regards,
Anil -
How to find out the maximum value in a Query within single material
Dear all,
Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material which is having more that one transaction..
EX:
MATERIAL BILLED VALUE
x with BILLED VALUE 100
x with BILLED VALUE120
y with BILLED VALUE 50
y with BILLED VALUE 80
z with BILLED VALUE 50
z with BILLED VALUE 60
in a analyser i have to display X with billed value 120 that is max in X material and
Y with billed value 80 that is max in Y material and
Z with billed value 60 that is max in Z material
In a query all the values are summing up. I.e for X its 220 and Y its 130 and Z its110 but we dont want to get total sum value we want individual values and the maximim of those values..........
We are using BW 7.0 version
Can any one help me out in this
Thxs in Advance
VenuVenu,
In your query try creating a formula, with the value of each record as the key figure in the formula.
In the aggregation tab select maximum in the exception aggregation dropdown and then select material as the reference characteristic
then when you include material in the rows it will only display the maximum value.
cheers
mark -
How to find out the maximum value
Dear all,
i have one query where in i have to calculate Excise Duty based on the maximum sales qantity of all materials with the corresponding sales value... i mean i wil get the maximum value of a individual material no matter how many sales has done.i wil pick up the maximum sales qty and the correspondig sales value....
This im able to solve by taking the condition as TOP 1..
Now my question is if the same material qty is sold with differnt value then i have to pick up the Max value and as usual the sales qty..... plz help me out
Material Sales Qty sales value
3000 10 kl 1000INR
3200 15 kl 1100 INR
4000 20 kl 1000INR
in this case my query is picking up the max qty of 20 and the value 1000 INR as i had taken TOP 1 on Sales qty ....
<b>
But In the below example for the same material i have to pick up the 3 rd row where the sales value is maximum and the corresponding sales qty 10 kl</b>
EX Material Sales Qty sales value
3000 10 kl 1000INR
3000 10 kl 1100 INR
3000 10 kl 1500INRHi,
U can use the restrict option fo the Material characteristics for sales value just drag and drop on columns >right click Properties> U have the option Calculated Result as Summation, Maximum, Minimum etc..just choose Maximum for ur case. -
Cap on Maximum value of payment in single payment run (F110)
Hi All,
we have a requirement to put a cap on maximum value of payment in payment run in F110. Kindly suggest me how we can do this.Is there any sta
Thanks & Regards
Deepak GargHi Deepak,
Please find below the answers to your queries.
1.Let us suppose that you have already posted a document with a payment method C( say for 255000 Euros). Later you go configure your company code specific payment method C and stipulate a limit of 250000 Euros as maximum amount . The maximum amount stipulation does not bind this invoice item which was created earlier. This item can be paid via payment method C. The maximum limit applies to documents posted after completion of your configuration.
2.In standard SAP payment amount limit is per payment method level, and cannot be set at payment run level.
The alternative option would be adding a "user exit" with the help of ABAP Team for this specific purpose. The second alternative, though not practicable, would be reviewing the proposal run and making the necessary changes to restrict the total payment amount.
Warm regards,
Murukan Arunachalam -
Summing and Finding Maximum in 2d array
So I have an 2d array of numbers and I am trying to find the maximum sum of the rows and give back the row number. So far I can get the sum and the maximum number but I need to give back the row number of the maximum value.
public static void RowSumRow (int[][] table)
static int sum[] = new int[5];
int region=0;
for (int row=0; row < table.length; row++)
sum [row] = 0;
for (int col=0; col < table[row].length; col++)
sum [row] = sum [row] + table[row][col];
int max = myMethods.maximumSearch(sum);
System.out.println("The maximal revenue is $" + max + " at region " + region);
}myMethods.maximumSearch
public static int maximumSearch(int a[])
int Max = a[0];
for (int index=0; index < a.length; index++)
if(Max < a[index])
Max = a[index];
return Max;
}this is correct right?
(the prarmeter rows is the rows that are to be tested)
public static void RowSumRow (int[][] table, int rows)
int sum[] = new int[rows];
int region=0;
for (int row=0; row < table.length; row++)
sum [row] = 0;
for (int col=0; col < table[row].length; col++)
sum [row] = sum [row] + table[row][col];
int max = myMethods.maximumSearch(sum);
for(int x=0; x < sum.length; x++)
if (max == sum[x])
region = x-1;
System.out.println("The maximal revenue is $" + sum[region] + " at region " + region);
}This does what I want it to do right? Ive tested a few times and it is working, but is it logically correct? -
Maximum value of Processes in Oracle 11g
Hi,
In our application, we do get the following error frequently.
ORA-12516, TNS:listener could not find available handler with matching protocol stack
When i searched about it, I learnt that the processes /sessions used might be exceeded.
So, I'm trying to alter the values of the system parameters - Processes & sessions for my DB.
The following link says the maximum value for PROCESSES is 'operating system dependent'
http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams188.htm#REFRN10175
The DB Host machine is Windows Server Enterprise and its 32-bit machine.
The DB is *"Oracle Database 11g Enterprise Edition Release 11.2.0.1.0"*
Can you please help me find out the maximum value of the PROCESSES parameter that we can set for this OS?
Let me know if my understanding of the issue is wrong.
Regards,
TamilHi,
I checked the v$resource_limit table,
Resource Name CurrentUtilization Max_Utilization Initial_Allocation Limit_Value
processes 119 150 150 150
sessions 124 158 248 248
I could see the current value for processes is 119 here. When i checked v$process few hours back, it was 145.
I could not use the command "ulimit -a" as its a DB installed in Windows box.
Can you help me to find out how i can find the value for Windows OS?
Thanks,
Tamil -
Finding minimum value in each row using dynamic query
need to find the minimum and maximum value from each row using dynamic query
[from curr] will be given as input
TukyDECLARE @t TABLE(a INT,b INT,c INT);
INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
SELECT *
, ( SELECT MAX(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS MaxVal
, ( SELECT MIN(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS MinVal
FROM @t;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Calculate maximum value of subarray while creating it using a case structure and shift registers
I have two 1D arrays that contain cyclical information (kind of like a sine wave). One that contains information on position in degrees and another that contains torque. I would like to calculate the maximum torque value each time the position is within a certain range (e.g. from 30-80 degrees). The ranges are repeated - that's why it is cyclical. I use the "in range" function, a case structure and shift registers to build a new array with values that fall within the range I specify - this was the easy part (see VI attached). I'm struggling with a way to calculate a maximum value for each subarray formed when values are "in range". Your help is much appreciated.
Solved!
Go to Solution.
Attachments:
Simple Calculate between anatomical position range.vi 16 KBIt's not really noise - it's more inconsistency. So a position output can run: 20, 30, 40, 50, 60 etc. OR, it could run: 21, 24, 32, 41, 44, 51, 59 etc. But, it is always cyclical.
Attached you will find a .csv file with the data arrays - I'm using POS (ANAT) degrees column (column D if you open in excel). There you also see torque in ft-lbs along with some other information.
Attachments:
025C.csv 224 KB -
Finding max value in column using java..
Hello there!!
I have a problem that i tried finding in google but did not get what i wanted.. that's why i hope you guys could help me out.
How do i find the maximum value in a column using resultset..
for example..
Connection con = DriverManager.getConnection("jdbc:mysql:///eproc","root", "");//eproc is dbase name in MySQL
Statement stmt=con.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT MAX(id) FROM cat_work_sor_category");now, how do i use resultset to make sure i get the max value and assign to integer variable...
Please do help me out.
Thankyou.Connection con =
DriverManager.getConnection("jdbc:mysql:///eproc","roo
t", "");//eproc is dbase name in MySQL
Statement stmt=con.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT MAX(id) FROM
cat_work_sor_category");
Integer MaxValue = new Integer(-1);
if(rs.next()){
MaxValue = rs.getInt(1);
int MAX_VALUE = MaxValue.intValue(); -
What is the best way to get the minimum or maximum value from an Array of numbers?
Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2]
What is the best way to find the minimum or maximum value in
that Array?
Right now, to get the maximum, I am looping through the
Array, and resetting a variable to the value if it is greater than
the existing value:Here's other approaches, the cookbook is your friend:
http://digitalmedia.oreilly.com/pub/a/oreilly/digitalmedia/helpcenter/actionscript30cookbo ok/chapter5.html?page=7
enjoy. -
How to find default value of a column ?
hi , alok again,
i have to find default value of a column.
Acutally i have found , column's max width, its nullability, precision, scale, type, but NOT default value.
I will have to use the default value and nullability while validating user's input.
ResultSetMetaData doesnot contain any method any such method...
Pls help,
how can i do so.
Any idea will be highly appreciated.
Thanks in adv.
AlokHi,
After you get the resultset from DatabaseMetaData.getColumns() as shown by sudha_mp you can use the following columns names to retrieve metadata information:
Each column description has the following columns:
TABLE_CAT String => table catalog (may be null)
TABLE_SCHEM String => table schema (may be null)
TABLE_NAME String => table name
COLUMN_NAME String => column name
DATA_TYPE int => SQL type from java.sql.Types
TYPE_NAME String => Data source dependent type name, for a UDT the type name is fully qualified
COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
BUFFER_LENGTH is not used.
DECIMAL_DIGITS int => the number of fractional digits
NUM_PREC_RADIX int => Radix (typically either 10 or 2)
NULLABLE int => is NULL allowed.
columnNoNulls - might not allow NULL values
columnNullable - definitely allows NULL values
columnNullableUnknown - nullability unknown
REMARKS String => comment describing column (may be null)
COLUMN_DEF String => default value (may be null)
SQL_DATA_TYPE int => unused
SQL_DATETIME_SUB int => unused
CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
ORDINAL_POSITION int => index of column in table (starting at 1)
IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.
SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
SCOPE_SCHEMA String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
SCOPE_TABLE String => table name that this the scope of a reference attribure (null if the DATA_TYPE isn't REF)
SOURCE_DATA_TYPE short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
Regards,
bazooka
Maybe you are looking for
-
My younger sister executed my firefox just at this afternoon(she originally use IE), and she saw something that can't be seen. How can I set a password for firefox so that everyone have to enter the password before executing firefox?
-
How to configure sales forcast and assign marketing budget
how to configure sales forcast and assign marketing budget
-
Preview How To - change keyboard shortcut for dictionary def.
Hi, I would like to know how to change the keyboard shortcut for checking the dictionary definition of a highlighted word in Preview. Thanks, Brandon
-
USER EXIT: Email notification after PO creation
Hi everyone! May I know if there exists a User Exit / BAdI in this following scenario: 1. An email notification outside SAP is sent whenever there is a creation of PO (Purchase Doc)? Please advise if this is possible. Points will be rewarded for usef
-
.flv movie quits when viewing in web browser
I'm still having problems with my flash movies. I'm using the .flv playback component in flash and when I preview my movie (an .flv file) in flash it plays all the way through, but when I view through a web browser the movie quits after 25 seconds (i