0% found this document useful (0 votes)
29 views6 pages

Semana 1

The document contains 7 Java programs that demonstrate basic programming concepts like: 1) Declaring and assigning variables of different data types and performing calculations on them 2) Importing packages and using methods like Scanner, Date, and System.out.printf 3) Creating classes and methods to write programs that convert between units (currency, temperature), calculate areas, and apply formulas like interest calculation.

Uploaded by

:V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views6 pages

Semana 1

The document contains 7 Java programs that demonstrate basic programming concepts like: 1) Declaring and assigning variables of different data types and performing calculations on them 2) Importing packages and using methods like Scanner, Date, and System.out.printf 3) Creating classes and methods to write programs that convert between units (currency, temperature), calculate areas, and apply formulas like interest calculation.

Uploaded by

:V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Carlos Gregorio Ramirez Ccayo

1-
package semana1sesion2;

public class caso02 {

public static void main (String [] args)


{
String nom="Carlos";
int n1=20, n2=10;
double prom;
prom=n1/n2;
System.out.println("mi nombre es:"+nom);
System.out.println("el promedio es: "+prom);

2-
package semana1sesion2;

import java.util.Date;

public class Semana1Sesion2 {


public static void main(String[] args) {
System.out.println("hola mundo");
System.out.println("hola mundo");
System.out.println("hola mundo");
System.out.println("hola mundo");

double value = 142587.250478;


Date today = new Date();
String message = "yo estoy aprendiendo";
System.out.printf("%%%n");
System.out.printf("%x%n", (int)value);
System.out.printf("%tD-%tT%n", today, today);
System.out.printf("%o%n", (int)value);
System.out.printf("%f%n", value);
System.out.printf("%e%n", value);
System.out.printf("%d%n", (int)value);
System.out.printf("%a%n", value);
System.out.printf("%b / %b%n", true, value < 0);
System.out.printf("%s%n", message);
System.out.printf("%c%n", message.charAt(0));

}
}

3-
import java.util.Scanner;
public class conversorDeMoneda {
public static void main(String[] args) {

Scanner leer= new Scanner(System.in);

System.out.print("ingrese la cantidad de soles: ");


double dolar=leer.nextDouble();
double soles = 3.48;
double cambio=dolar*soles;
System.out.println("el cam1bia a dolares a soles es de:
"+cambio);
leer.close();
}
}

4-
import java.util.Scanner;
public class conversorFarenheit{
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
System.out.print("ingrese los centigrados a convertir: ");
double centigrados= leer.nextDouble();
double farenheit=(centigrados*9/5)+32;
System.out.print("la convercion a farenheit es de: "+farenheit);
leer.close();
}

}
5-
import java.util.Scanner;
public class CalculadoraDeAreaGeometrica {
public static void main(String[] args) {
Scanner leer= new Scanner(System.in);
System.out.print("ingrese el ancho de la figura:");
double ancho = leer.nextDouble();
System.out.print("ingrese el largo de la figura:");
double largo = leer.nextDouble();
double resultado=ancho*largo;
System.out.println("el area de la figura es de "+
resultado+"m2");
leer.close();
}}
6-
import java.util.Scanner;
public class programaIGV{
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
System.out.print("Ingrese la cantidad: ");
float monto = leer.nextFloat();
float igv = 0.18f;
float resultado = (monto*igv);
System.out.print("el IGV es de: "+resultado+ " soles");
leer.close();
}
}

7-
import java.util.Scanner;
public class formulaMatematica {
public static void main(String[] args) {
//---declaracion de variables y
Scanner leer=new Scanner(System.in);
System.out.print("ingrese el prestamo: ");
double principal = leer.nextDouble();
System.out.print("ingrese la taza de interes (%): ");
double taza = leer.nextDouble()/100.00;
System.out.print("ingrese el tiempo total en años: ");
double tiempo = leer.nextDouble();
//----------formula con 3 variables----------------
double interes= principal*taza*tiempo;
System.out.println("El interez simple es de: "+ interes+"
soles");
leer.close();
}

You might also like