🔒 Closed Muntikan na kong mawalan nang mata

Status
Not open for further replies.
gawin daw ser na yung may System.out.print()
View attachment 658267
pa try nga ko nito?


import java.util.Scanner;

class GetInputFromUser {
public static void main(String args[]) {
int a;
float b;
String s;

Scanner in = new Scanner(System.in);
System.out.println("Enter a string");
s = in.nextLine();
System.out.println("You entered string " + s);

System.out.println("Enter an integer");
a = in.nextInt();
System.out.println("You entered integer " + a);

System.out.println("Enter a float");
b = in.nextFloat();
System.out.println("You entered float " + b);
}
}
 
sige po salamat talaga ng marami
pa try ako nito

Here I'm using in.nextLine(); to get the String which the user enters.

import java.util.Scanner;

class GetInputFromUser {
public static void main(String args[]) {
int a;
float b;
String s;

Scanner in = new Scanner(System.in);
System.out.println("Enter a string");
s = in.nextLine();
System.out.println("You entered string " + s);

System.out.println("Enter an integer");
a = in.nextInt();
System.out.println("You entered integer " + a);

System.out.println("Enter a float");
b = in.nextFloat();
System.out.println("You entered float " + b);
}
}
 
pa try nga ko nito?


import java.util.Scanner;

class GetInputFromUser {
public static void main(String args[]) {
int a;
float b;
String s;

Scanner in = new Scanner(System.in);
System.out.println("Enter a string");
s = in.nextLine();
System.out.println("You entered string " + s);

System.out.println("Enter an integer");
a = in.nextInt();
System.out.println("You entered integer " + a);

System.out.println("Enter a float");
b = in.nextFloat();
System.out.println("You entered float " + b);
}
}
eto po labas
 

Attachments

  • Screenshot_2019-08-03-23-10-16-95.webp
    Screenshot_2019-08-03-23-10-16-95.webp
    63.3 KB · Views: 20
nag run ba yan bago ng error?
eto next pa try, checkmate na yan pag gumana 'to ->




import java.util.Scanner;

public class Example
{
public static void main(String[] args)
{
int number1, number2, sum;

Scanner input = new Scanner(System.in);

System.out.println("Enter First multiple");
number1 = input.nextInt();

System.out.println("Enter second multiple");
number2 = input.nextInt();

sum = number1 * number2;

System.out.printf("The product of both number is %d", sum);
}
}
 
eto next pa try, checkmate na yan pag gumana 'to ->




import java.util.Scanner;

public class Example
{
public static void main(String[] args)
{
int number1, number2, sum;

Scanner input = new Scanner(System.in);

System.out.println("Enter First multiple");
number1 = input.nextInt();

System.out.println("Enter second multiple");
number2 = input.nextInt();

sum = number1 * number2;

System.out.printf("The product of both number is %d", sum);
}
}
Resource leak: 'input' is never closed
 
eto next pa try, checkmate na yan pag gumana 'to ->




import java.util.Scanner;

public class Example
{
public static void main(String[] args)
{
int number1, number2, sum;

Scanner input = new Scanner(System.in);

System.out.println("Enter First multiple");
number1 = input.nextInt();

System.out.println("Enter second multiple");
number2 = input.nextInt();

sum = number1 * number2;

System.out.printf("The product of both number is %d", sum);
}
}
yung Pizza2.java ser Resource Leak error

Screenshot_2019-08-03-23-18-10-39.webp
 
EDITED :
Eto Isulat mo sa papel, isave mo sa Notepad ng selpon mo,

import java.util.Scanner;


Class main
{


public static void main(string[] args)
{
double diameter;
double radius;
double square;
double area;
double price;
double result;


Scanner input = new Scanner(You do not have permission to view the full content of this post. Log in or register now.);


System.out.println("Enter Diameter ");
diameter = input.nextDouble();
System.out.println("Enter Price ");
price = input.nextDouble();


radius = diameter * 2;
square = radius*radius;
area = 3.14*square;
result = price/area;


System.out.printIn("Kalahati ng pizza ay " + radius);


System.out.printIn("Price per square inch is " + result);


}


}
 
Eto Isulat mo sa papel, isave mo sa Notepad ng selpon mo,

import java.util.Scanner;


Class Pizza
{


public static void Main()
{
float diameter;
float radius;
float square;
float area;
float price;
float result;


Scanner input = new Scanner(You do not have permission to view the full content of this post. Log in or register now.);


System.out.println("Enter Diameter ");
diameter = input.nextInt();
System.out.println("Enter Price ");
price = input.nextInt();


radius = diameter * 2;
square = radius*radius;
area = 3.14*square;
result = price/area;


System.out.printf("Kalahati ng pizza ay %f", radius);


System.out.printf("Price per square inch is %f", result);


}


}
nasulat ko na ser Thank you talaga.. :)
 
Status
Not open for further replies.

About this Thread

  • 42
    Replies
  • 841
    Views
  • 7
    Participants
Last reply from:
touchstar

Trending Topics

Online now

Members online
1,132
Guests online
2,175
Total visitors
3,307

Forum statistics

Threads
2,298,281
Posts
29,122,068
Members
1,202,328
Latest member
sangrett
Back
Top