This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
ESTRUCTURA SECUENCIAL
1°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema.nº2;
import java.io.*;
/**
*
* @author GARCIA */
public class ProblemaNº1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
int n1,n2,s;
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("numero 1:");
n1 = Integer.parseInt(in.readLine());
System.out.println("numero 2:");
n2 = Integer.parseInt(in.readLine());
s=n1+n2;
System.out.println("");
System.out.println("suma: " +s);
}
}
2°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema3;
import java.io.*;
/**
*
* @author GARCIA
*/
public class Problema2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
//varible
int n1,n2,c,r;
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("numero 1:");
n1 = Integer.parseInt(in.readLine());
System.out.println("numero 2:");
n2 = Integer.parseInt(in.readLine());
//proceso
c=n1/n2;
r=n1%n2;
//salida
System.out.println("");
System.out.println("cociente: " +c);
System.out.println("residuo: " +r);
// TODO code application logic here
}
}
3°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema.pkg4;
import java.io.*;
/**
*
* @author GARCIA
*/
public class Problema3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
//variable
float vv,igv,pv;
//entrada
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("valor de venta:");
vv =Float.parseFloat(in.readLine());
//proceso
igv = vv *0.18f;
pv = vv+ igv;
//salida
System.out.println("");
System.out.println("igv: " +igv);
System.out.println("precio de venta: " +pv);
// TODO code application logic here
}
}
4°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema04;
import java.io.*;
/**
*
* @author GARCIA
*/
public class PROBLEMA04 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
short n,r;
int a;
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("a: ");
a=Integer.parseInt(in.readLine());
System.out.println("n: ");
n=Short.parseShort(in.readLine());
// TODO code application logic here
r=(short)Math.pow((double)a, (1/(double)n));
System.out.println("");
System.out.println("Radicación: "+r);
// TODO code application logic here
}
}
5°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema05;
import java.io.*;
/**
*
* @author GARCIA
*/
public class PROBLEMA05 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
short n,r;
int a;
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("a: ");
a=Integer.parseInt(in.readLine());
System.out.println("n: ");
n=Short.parseShort(in.readLine());
// TODO code application logic here
r=(short)Math.pow((double)a, (1/(double)n));
System.out.println("");
System.out.println("Radicación: "+r);
// TODO code application logic here
}
}
6°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema06;
import java.io.*;
/**
*
* @author GARCIA
*/
public class PROBLEMA06 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int n, ni, r;
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Número: ");
n=Integer.parseInt(in.readLine());
r=n%10;
n=n/10;
ni=r*10;
r=n%10;
n=n/10;
ni=(ni+r)*10;
r=n%10;
n=n/10;
ni=(ni+r)*10;
r=n%10;
n=n/10;
ni=(ni+r)*10;
ni=ni+n;
System.out.println("");
System.out.println("Inverso: " + ni);
}
}
7°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema07;
import java.io.*;
/**
*
* @author GARCIA
*/
public class PROBLEMA07 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int n,s;
BufferedReader in =new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Número: ");
n=Integer.parseInt(in.readLine());
s=(n*(n+1))/2;
System.out.println("");
System.out.println("Suma: " + s);
}
}
8°
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package problema8;
import java.io.*;
/**
*
* @author GARCIA
*/
public class Problema8 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {