|
Example 1:
Input : s ="()";
Output : true
Example 2:
Input: s = "() [] {}"
Output : true
Example 3:
Input : s = "(]"
Output : false
Example 4:
Input : s = "([)]"
Output : fasle
Example 5:
Input : s = "{[] }"
Output : true
The Condition should match s ="()" true condition. or s ="(" should return false … same for other conditions as well
|
|
|
|
|
OK, and do you have an actual question?
|
|
|
|
|
If you're looking for the code that evaluates enclosing brackets to validate they are matched up and nested correctly, that's not going to happen.
|
|
|
|
|
<pre>You are required to analyze the performance for Principles of Computer Programming subject
containing 135 students. Your program will prompt for final marks of each student, accumulate
the total and calculate the average. Display the average mark and the grade obtained based on
the information in Table 2 below. Design a pseudocode and write a full java program to provide
the solution.
Table 2: (Grade Category based on Average Mark)
--
Average mark range // Grade Category
Below 50 - Low
50 to 79 - Good
80 and above - Excellent </pre>
|
|
|
|
|
This is a very basic beginner program in any language. The whole intent is to learn with this. If this was an assignment you should attempt it yourself.
Pseduocode steps:
1. Take marks of a student as input
2. Calculate average of the input marks
3. Based on table 2 category, find the grade using average marks
4. Print the average and grades
5. Repeat step 1 to 4 for 135 students
Please try of. Post specific query if you face trouble. Don't forget to share what you tried and where you get stuck.
|
|
|
|
|
i tried but... im confused and slow and this def wrong
import java.util.*;
public class Mark {
public Mark () {
}
public static void main(String args[]) {
String grade;
int avgMark;
int studentMark;
Scanner input = new Scanner (System.in);
System.out.println(" Your Mark: ");
studentMark = input.nextInt();
avgMark = (total + finalMark) / 2
if(avgMark >= 80)
{
System.out.println("Grade: Excellent");
}
else if (avgMark >= 50 && avgMark <= 79) {
System.out.println(" Grade: Good ");
}
else if (avgMark <= 50) {
System.out.println(" Grade: Low ");
}
}
}
|
|
|
|
|
|
Hey guys so iam in a bit of a stump. Me and a friend have been working on a hard drive wiping software that is absolutely amazing. Well it turned out to be that way by chance.... It is in perfect working order... I was helping with Linux side of things. Anyways my friend has had a recent job change and is being bombarded with work. He is unable to help with the project anymore, considering he has a stake in the software and even gets paid, its kind of odd for him to take off. The software uses Linux command lines, udev, node.js, php, angular and batch for the core of its operation. It is by far the most advanced batch disk wiping software currently in development and has been in development for over a year.
I am looking for a skilled nodejs programmer and can give a break down of how the software works. I need help with the nodejs portion of the software. Anyone that is willing to devote some of their spare time will not be disappointed.
If there are any takers please go ahead and respond to me with your skype or discord info.
|
|
|
|
|
This site does not provide a free recruitment service. If you wish to advertise then please contact the sales department.
|
|
|
|
|
Hi there,
i upgraded the log4j 1.x to log4j2 2.12 Version and therefore changed the xml file.
Here is my log4j2.xml:
---------------------------------------------------
="1.0"="UTF-8"
<Configuration>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<PatternLayout>
<pattern>%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n</pattern>
</PatternLayout>
</Console>
<RollingFile name="DefaultAppender" fileName="../var/Project-server.log" filePattern="'.'yyyy-MM-dd">
<PatternLayout>
<pattern>%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"</pattern>
</PatternLayout>
</RollingFile>
<RollingFile name="ErrorAppender" fileName=".../var/Project-server_error.log" filePattern="'.'yyyy-MM-dd">
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout>
<pattern>%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"</pattern>
</PatternLayout>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="com.mchange" level="WARN">
</Logger>
<Logger name="com.dwin.Project.common.util" level="WARN">
</Logger>
<Logger name="com.dwin.db" level="DEBUG">
</Logger>
<Logger name="com.dwin.util" level="DEBUG">
</Logger>
<Logger name="org.apache.cxf" level="WARN">
</Logger>
<Logger name="org.mortbay" level="WARN">
</Logger>
<Logger name="org.springframework" level="INFO">
</Logger>
<Root level="DEBUG">
<AppenderRef ref="DefaultAppender"/>
<AppenderRef ref="ErrorAppender"/>
<AppenderRef ref="ConsoleAppender"/>
</Root>
</Loggers>
</Configuration>
---------------------------------------------------
Here is the old log4j.xml 1.x:
---------------------------------------------------
="1.0"="UTF-8"
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"/>
</layout>
</appender>
<appender name="DefaultAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="File" value="../var/Project-server.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"/>
</layout>
</appender>
<appender name="ErrorAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="File" value="../var/Project-server_error.log"/>
<param name="threshold" value="ERROR"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"/>
</layout>
</appender>
<logger name="com.mchange">
<level value="WARN"/>
</logger>
<logger name="com.dwin.Project.common.util">
<level value="WARN"/>
</logger>
<logger name="com.dwin.Project.server">
<level value="DEBUG"/>
</logger>
<logger name="com.dwin.db">
<level value="DEBUG"/>
</logger>
<logger name="com.dwin.util">
<level value="DEBUG"/>
</logger>
<logger name="org.apache.cxf">
<level value="WARN"/>
</logger>
<logger name="org.mortbay">
<level value="WARN"/>
</logger>
<logger name="org.springframework">
<level value="INFO"/>
</logger>
<root>
<level value="DEBUG"/>
<appender-ref ref="DefaultAppender"/>
<appender-ref ref="ErrorAppender"/>
<appender-ref ref="ConsoleAppender"/>
</root>
</log4j:configuration>
---------------------------------------------------
However i get the following error message when i execute my batch.file:
---------------------------------------------------
2020-10-16 15:40:26,373 main ERROR The parameter is null: policy
2020-10-16 15:40:26,377 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element RollingFile are invalid: field 'policy' has invalid value 'null'
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:208)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:651)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:668)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at com.dwin.Project.server.ProjectServer.<clinit>(ProjectServer.java:10)
2020-10-16 15:40:26,384 main ERROR The parameter is null: policy
2020-10-16 15:40:26,385 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element RollingFile are invalid: field 'policy' has invalid value 'null'
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:208)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:651)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:668)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at com.dwin.Project.server.ProjectServer.<clinit>(ProjectServer.java:10)
2020-10-16 15:40:26,388 main ERROR Null object returned for RollingFile in Appenders.
2020-10-16 15:40:26,389 main ERROR Null object returned for RollingFile in Appenders.
2020-10-16 15:40:26,398 main ERROR Unable to locate appender "DefaultAppender" for logger config "root"
2020-10-16 15:40:26,399 main ERROR Unable to locate appender "ErrorAppender" for logger config "root"
---------------------------------------------------
Can someone help?
|
|
|
|
|
org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element RollingFile are invalid: field 'policy' has invalid value 'null'
Check your code to see why this value is null.
|
|
|
|
|
I am trying to convert a JAVA POJO object with a JsonObject to a String as following:
class MyPojo {
public MyPojo(String sName, JsonObject obj)
{
this.sName = sName;
this.tJsonObj = obj;
}
public String sName;
public javax.json.JsonObject tJsonObj;
};
javax.json.JsonObject jsonObj = JsonUtils.toJsonObject("{\"key\": 123}");
ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper.ObjectMapper();
JsonNode node = mapper.valueToTree(new MyPojo("myname", jsonObj));
String jsonStr = node.toString();
I am getting jsonStr value as:
{"sName":"myname","tJsonObj":{"key":{"integral":true,"valueType":"NUMBER"}}}
How can I get jsonStr value as:
{"sName":"myname","tJsonObj":{"key":123}}
JsonUtils.toJsonObject is my own utility method to get JsonObject from String .
|
|
|
|
|
Hi guys I created a project in android studio which has 2 types of login system the
1. Sign in with email and password
2. Login with phone number
I have a problem in login with phone number
I have 3 activities in project which in
1. I am taking the the login with email and password
2. Is I am taking the login with phone number
3. I am checking if the email is verified or not
So if the email is verified the person can go to app inside
But when I login with phone number it go to the 3rd activitiy to the email verification but I want it go to the app not to the verify email activity
Here is my code for main activity
----------
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
currentUser = mAuth.getCurrentUser();
myViewPager = (ViewPager) findViewById(R.id.main_tabs_pager);
myTabsaccessorAdopter = new TabsAccessorAdopter(getSupportFragmentManager());
myViewPager.setAdapter(myTabsaccessorAdopter);
myTabLayout = (TabLayout) findViewById(R.id.main_tabs);
myTabLayout.setupWithViewPager(myViewPager);
}
@Override
protected void onStart()
{
super.onStart();
if (currentUser == null)
{
SendUserToLoginActivity();
}
else
{
if(!currentUser.isEmailVerified())
{
SendUserToVerifyEmailActivity();
}
}
}
private void SendUserToLoginActivity()
{
Intent loginIntent = new Intent(MainActivity.this,LoginActivity.class);
startActivity(loginIntent);
}
private void SendUserToVerifyEmailActivity()
{
Intent verifyEmailIntent = new Intent(MainActivity.this,VerifyEmailActivity.class);
startActivity(verifyEmailIntent);
}
private void SendUserToMainActivity()
{
Intent mainIntent = new Intent(MainActivity.this,MainActivity.class);
startActivity(mainIntent);
}
}
-------------------------------
And here is my PHone login code
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register__with__phone__number_);
mAuth =FirebaseAuth.getInstance();
loadingBar = new ProgressDialog(this);
Initialize();
Second_Fourth.registerCarrierNumberEditText(Second_Fifth);
First_Fifth.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String code = First_Fourth.getSelectedCountryCode();
First_Layout.setVisibility(View.INVISIBLE);
Second_Layout.setVisibility(View.VISIBLE);
Third_Layout.setVisibility(View.INVISIBLE);
Second_Fourth.setCountryForPhoneCode(Integer.parseInt(code));
}
});
Second_Seven.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String phoneNumber = Second_Fifth.getText().toString();
phoneNumber = Second_Fourth.getFullNumberWithPlus();
if(TextUtils.isEmpty(phoneNumber))
{
Toast.makeText(Register_With_Phone_Number_Activity.this, "Number is recquired", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("Phone verification");
loadingBar.setMessage("please wait...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNumber,60,TimeUnit.SECONDS,Register_With_Phone_Number_Activity.this,mCallbacks);
}
}
});
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks()
{
@Override
public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential)
{
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onVerificationFailed(@NonNull FirebaseException e)
{
Toast.makeText(Register_With_Phone_Number_Activity.this, "Invalid phone number", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
First_Layout.setVisibility(View.INVISIBLE);
Second_Layout.setVisibility(View.VISIBLE);
Third_Layout.setVisibility(View.INVISIBLE);
}
@Override
public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken)
{
super.onCodeSent(s, forceResendingToken);
loadingBar.dismiss();
mVerificationId = s;
mResendToken = forceResendingToken;
First_Layout.setVisibility(View.INVISIBLE);
Second_Layout.setVisibility(View.INVISIBLE);
Third_Layout.setVisibility(View.VISIBLE);
}
};
Second_Eight.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
SendUserToRegisterNumberActivity();
}
});
Third_Fourth.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String verificationcode = Third_Third.getText().toString();
if (verificationcode.isEmpty())
{
Toast.makeText(Register_With_Phone_Number_Activity.this, "Verification code first", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("verification code");
loadingBar.setMessage("please wait...");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId,verificationcode);
signInWithPhoneAuthCredential(credential);
}
}
});
}
private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential)
{
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
{
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful())
{
loadingBar.dismiss();
Toast.makeText(Register_With_Phone_Number_Activity.this, "Logged in Successful", Toast.LENGTH_SHORT).show();
SendUserToMainActivity();
}
else
{
loadingBar.dismiss();
Toast.makeText(Register_With_Phone_Number_Activity.this, "Error", Toast.LENGTH_SHORT).show();
}
}
});
}
private void Initialize()
{
First_Layout = (LinearLayout) findViewById(R.id.first_layout);
Second_Layout = (LinearLayout) findViewById(R.id.second_layout);
Third_Layout = (LinearLayout) findViewById(R.id.third_layout);
First_Fifth = (Button) findViewById(R.id.first_fifth);
Second_Seven = (Button) findViewById(R.id.second_seven);
Second_Eight = (Button) findViewById(R.id.second_eight);
Third_Fourth = (Button) findViewById(R.id.third_fourth);
First_Fourth = (CountryCodePicker) findViewById(R.id.first_fourth);
Second_Fourth = (CountryCodePicker) findViewById(R.id.second_fourth);
Second_Fifth = (EditText) findViewById(R.id.second_fifth);
Third_Third = (EditText) findViewById(R.id.third_third);
}
private void SendUserToRegisterNumberActivity()
{
Intent registernumberIntent = new Intent(Register_With_Phone_Number_Activity.this,Register_With_Phone_Number_Activity.class);
startActivity(registernumberIntent);
}
private void SendUserToMainActivity()
{
Intent mainIntent = new Intent(Register_With_Phone_Number_Activity.this,MainActivity.class);
startActivity(mainIntent);
}
}
|
|
|
|
|
3. Modify the code from the last week’s theoretical lecture (HelloWorldPanel,
HelloWorldFrame) to make a frame and a panel that show your full name
at each corner of the frame. Let the names be (MyNamePanel,
MyNameFrame) and choose whatever formats you want.
|
|
|
|
|
We didn't attend that lecture so can't really help you with your homework
|
|
|
|
|
|
servlet problem and mapping with sql
server issues
|
|
|
|
|
if anybody have soltution tell me its urgent please
|
|
|
|
|
Member 14941356 wrote: servlet problem and mapping with sql
You have hardly shared about what you are doing and the issue faced.
Please look at the forum guidelines: Java Discussion Boards
|
|
|
|
|
|
You haven't described any kind of problem so there is no way anyone is going to be able to tell you what's wrong.
You might want to start by reading this: Asking questions is a skill[^]
|
|
|
|
|
I have created a spring boot + thymeleaf application with spring security for securing the requests. The application should also be providing a rest api to communicate with other applications(other front-end framework, mobile app). For this I chose to go with OAuth2 for securing the rest api and I stumbled across keycloak which I think suits my interest.
As of now the security configuration class extends WebSecurityConfigurerAdapter and not KeycloakWebSecurityConfigurerAdapter and hence I am using the following security constraints in my application.properties :
keycloak.security-constraints[0].authRoles[0]=user
keycloak.security-constraints[0].securityCollections[0].patterns[0]=/hello
I am thinking of using spring security to secure the normal requests and use keycloak for the rest api. I want each of them to work independent of the other. That is, even if I do not have the keycloak server running I need my web app to serve the web pages(secured by spring security) and the rest API will only work when keycloak is running(secured by keycloak). Currently, the keycloak client is setup with access type : public and a redirect will be made to keycloak authentication page when I try to access any request with pattern /hello/*(these are not rest api's as of now). I will be changing the access type to bearer-only for the rest api's. I have permitted the request to /hello/ without any authentication in the configure method in spring security settings :
http.authorizeRequests()
.antMatchers("/user").hasAnyRole("ADMIN", "USER")
.antMatchers("/admin").hasRole("ADMIN")
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.antMatchers("/hello").permitAll().anyRequest().authenticated().and().formLogin()
.loginPage("/login")
.defaultSuccessUrl("/", true)
.failureUrl("/login-error").permitAll().and()
.logout()
.invalidateHttpSession(true)
.logoutSuccessUrl("/login")
.logoutUrl("/logout");
Is this the right way to deal with my requirement? Should I use microservices to accomplish the same?. I am more concerned about whether it is the right way to do things regardless of whether the way I am doing would work or not. Any suggestions and/or improvements are welcome. Thanks.
|
|
|
|
|
so, i was doing some programming with eclipse and stuff. But then i noticed that all of my .JAR files suddenly looked like a pinguin with some painting stuff on his hands. i need help, cause im not sure what is going on!! I use windows.
[SOLVED] I had to right click a JAR file, and "press open in application" then select Java JDK. For some reason i had two of those...
modified 1-Sep-20 4:01am.
|
|
|
|
|
Member 14927382 wrote: (no trashmail please) Then remove your email address. You'll get a notification from the system when someone replies. No need to advertise your email.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Also, stop spamming.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|