What's new

Closed Mga Master IT sa Coding ng JAVA pa solve neto

Status
Not open for further replies.

Nihilosphy

Eternal Poster
Established
Joined
Aug 9, 2016
Posts
775
Reaction
512
Points
416
Gumawa daw kami ng algorithm neto

bali ang lesson namin Basic palang naman ng Java

kaso di namin magets pano i code to..

Problem:

Given the radius, in inches, and price of a pizza, design an algorithm to find and display the price of the pizza per square inch.
 
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
public class JavaApplication1 {

public static void main(String[] args) {

DecimalFormat df = new DecimalFormat("0.00");
String x=JOptionPane.showInputDialog("Enter Radius");
String y=JOptionPane.showInputDialog("Enter Price");
double y2=Double.parseDouble(y);
double x2=Double.parseDouble(x);
double radius= x2/2;
double area=radius*radius;

JOptionPane.showMessageDialog(null,df.format(y2/(area*3.14)));
}

}

Src: You do not have permission to view the full content of this post. Log in or register now.
 
p*ta eto rin ung assignment ko eh same school ata tau eh.sarap hampasin ng tubo prof ko kaka enroll ko lang last week tapos binigyan ako netong assignment.tinanong ko kung pwede niya ko turuan ng basic sabi sakin hindi na daw pwede kasi tapos na daw siya mag turo last last week pa
 
p*ta eto rin ung assignment ko eh same school ata tau eh.sarap hampasin ng tubo prof ko kaka enroll ko lang last week tapos binigyan ako netong assignment.tinanong ko kung pwede niya ko turuan ng basic sabi sakin hindi na daw pwede kasi tapos na daw siya mag turo last last week pa
ganun talaga paps, late enrollies ka ata paps
 
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
public class JavaApplication1 {

public static void main(String[] args) {

DecimalFormat df = new DecimalFormat("0.00");
String x=JOptionPane.showInputDialog("Enter Radius");
String y=JOptionPane.showInputDialog("Enter Price");
double y2=Double.parseDouble(y);
double x2=Double.parseDouble(x);
double radius= x2/2;
double area=radius*radius;

JOptionPane.showMessageDialog(null,df.format(y2/(area*3.14)));
}

}

Src: You do not have permission to view the full content of this post. Log in or register now.
double x2=Double.parseDouble(x);
double radius= x2/2;
paps bakit mo dinivide sa 2 yung radius?
 
Java:
import java.text.DecimalFormat;
import java.util.Scanner;
public class Price {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        DecimalFormat df = new DecimalFormat("0.00");
        System.out.println("Enter the Radius (in Inches): ");
        double radius = in.nextDouble();
        System.out.println("Enter the Price: ");
        double price = in.nextDouble();
        double price_per_square_inch = price / (radius * radius * Math.PI);
        String result = df.format(price_per_square_inch);
        System.out.println("Price per square inch: "+result);
    }
}
 
Java:
import java.text.DecimalFormat;
import java.util.Scanner;
public class Price {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        DecimalFormat df = new DecimalFormat("0.00");
        System.out.println("Enter the Radius (in Inches): ");
        double radius = in.nextDouble();
        System.out.println("Enter the Price: ");
        double price = in.nextDouble();
        double price_per_square_inch = price / (radius * radius * Math.PI);
        String result = df.format(price_per_square_inch);
        System.out.println("Price per square inch: "+result);
    }
}

eto yung tama sir, yung unang sagot mali eh
 
Status
Not open for further replies.
Back
Top