|
hi..how can I scan a number from a user..and save it?
|
|
|
|
|
Probably by using some sort of scanning device. But without more information it is impossible to be sure.
|
|
|
|
|
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);
printf("You entered: %d", number);
return 0;
}
Output
Enter a integer: 25
You entered: 25
|
|
|
|
|
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
int i = 4;
double d = 4.0;
String s = "HackerRank ";
Scanner scan = new Scanner(System.in);
int i1;
double d1;
String s1;
i1 = scan.nextInt();
d1 = scan.nextDouble();
s1 = scan.nextLine();
s1 = scan.nextLine();
System.out.println(i+i1);
System.out.println(d+d1);
System.out.println(s+s1);
scan.close();
}
}
|
|
|
|
|
import java.util.Scanner;
public class test
{
public static final int SENTINEL = -1;
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int score = 0;
int sum = 0;
System.out.println("Enter numbers here");
while (score >= 0) {
if (score <= -1) {
score = kb.nextInt();
sum += score;
score = 0;
}
System.out.println(sum);
}
}
}
|
|
|
|
|
If there are any deadlock cases in production environment, then, how can we identify it?
|
|
|
|
|
Code analysis, unit testing, full testing etc. Try Google (again) to find research papers on the subject.
|
|
|
|
|
Quote: A deadlock occurs when two or more threads in the JVM form a cyclic dependency with each other.
Quote: Click to Tweet
So, How to Diagnose and Troubleshoot Java Deadlocks?
There are various options available to troubleshoot deadlock situations.
1. The naïve way: Kill the process and cross your fingers
You could kill the application server process and hope that when the application server starts again, the problem will go away. However, restarting the application server is a temporary fix that will not resolve the root-cause. Deadlocks could get triggered again when the application server comes back up.
2. The laborious way: Take thread dumps in your cluster of JVMs
You could take thread dumps. To trigger a thread dump, send a SIGQUIT signal to the JVM. (On UNIX, that would be a “kill -3” command and on Windows, that would be a “Ctrl-Break” in the console).
Typically, you would need to capture a series of thread dumps (example: 6 thread dumps spaced 20 seconds apart) to infer any thread patterns – just a static thread dump snapshot may not suffice
modified 5-Dec-18 6:43am.
|
|
|
|
|
hi..I need generate a Random array for make a bank account number. the users can have several account number. I defined account number in a class with name "user". how can i define this in this class and how can I use that in main class? 
|
|
|
|
|
Why a random value? Bank account numbers need to be unique so you should use a sequencing system so each generated number is greater than the previous.
|
|
|
|
|
this is just a class project..so I need get a Random number..random array..how can I?
|
|
|
|
|
|
i want generate some Random numbers..then put them in a array..this array is the bank account numbers for each user..now how can I define this in new class?
|
|
|
|
|
Decide how long the array needs to be and then generate a random value for each element in the array.
|
|
|
|
|
The array is Unknown.. may 1, may 2, may10!!!
|
|
|
|
|
Sorry, I have no idea what that is supposed to mean. Try showing the actual Java code that you are trying to use.
|
|
|
|
|
Is
javascript is overcoming by web assembly language ??
|
|
|
|
|
This forum is for technical issues with Java. Javascript is something totally different, and Google will most likely be the best source for your query.
|
|
|
|
|
|
hey I have code to write code in java and I need help can someone write this code for me ?
Write a program that will allow a user to play Aristotle's Puzzle. You must use a class Tile.java that represents each tile, the class must have two variables:
-boolean placed
-int value
You must use 2 arrays of Tiles:
the board
the available Tiles for placement
|
|
|
|
|
Short answer: No.
Longer answer: Your homework is given to test your knowledge, not to test your ability to get someone else to do your work. Think about the problem, write some notes about the properties that you need to create, the methods required to move the objects around etc. You may find that it is not as difficult as you think.
|
|
|
|
|
I don’t gonna do it I’m willing to pay someone to do it for me 
|
|
|
|
|
This is still the wrong place.
|
|
|
|
|
.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
import java.util.*;
import java.io.*;
class Codechef
{
public static void main(String[] args) throws Exception
{
BufferedReader a=new BufferedReader(new InputStreamReader(System.in));
int tc=Integer.parseInt(a.readLine());
Solution s = new Solution();
for(int i=0;i<tc;i++)
s.solve();
}
}
class Solution
{
boolean check(String str,List<String> list)
{
if(list.indexOf(str)!=-1)
return true;
return false;
}
void sum(List<Double> list)
{
Double temp = 0.0;
for (double i: list)
temp += i;
int result=temp.intValue();
System.out.println(result);
}
void solve() throws Exception
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(b.readLine());
String str;
double temp;
int result;
List<String> wordlist = new ArrayList<String>();
List<Double> timelist = new ArrayList<Double>();
for(int k=0;k<n;k++)
{
str = b.readLine();
if(check(str,wordlist))
{
int i= wordlist.indexOf(str);
temp = timelist.get(i);
temp = temp/2;
timelist.add(temp);
}
else
{
temp = 2;
for(int i=1;i<str.length();i++)
{
if(str.charAt(i)=='d' || str.charAt(i)=='f')
if(str.charAt(i-1)!='d' && str.charAt(i-1)!='f')
temp+=2;
else
temp+=4;
if(str.charAt(i)=='j' || str.charAt(i)=='k')
if(str.charAt(i-1)!='j' && str.charAt(i-1)!='k')
temp+=2;
else
temp+=4;
}
wordlist.add(str);
timelist.add(temp);
}
}
sum(timelist);
}
}
|
|
|
|