i need find cedulaIdentidad of clientes array that buy a nokia at a lower price
i have a array of clientes who have a nombre, cedulaIdentidad, marcaCelular y precioCelular. and i have four opcion of telephone, nokia, motorola, lg and kyocera. i need find cedulaIdentidad of the client that buy a nokia at the lowe price. thanks for the help.
package recursos;
public class Cliente {
private String nombreCliente;
private int cedulaIdentidad;
private int precioCelular;
private String marcaCelular;
public Cliente(String nombre, int cedulaIdentidad, String marcaCelular, int precioCelular){
this.nombreCliente=nombre;
this.cedulaIdentidad=cedulaIdentidad;
this.precioCelular=precioCelular;
this.marcaCelular=marcaCelular;
}
public Cliente() {
}
public String getNombreCliente() {
return nombreCliente;
}
public int getCedulaIdentidad() {
return cedulaIdentidad;
}
public int getPrecioCelular() {
return precioCelular;
}
public void setPrecioCelular(int precioCelular) {
this.precioCelular = precioCelular;
}
public void setNombreCliente(String nombreCliente) {
this.nombreCliente = nombreCliente;
}
public void setCedulaIdentidad(int cedulaIdentidad) {
this.cedulaIdentidad = cedulaIdentidad;
}
public String getMarcaCelular() {
return marcaCelular;
}
public void setMarcaCelular(String marcaCelular) {
this.marcaCelular = marcaCelular;
}
}
package principal1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import recursos.Cliente;
public class Principal1 {
public static void main(String args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Cliente clientes = new Cliente[4];
int opc = 0;
int ventasLG = 0;
int ventasKyocera = 0;
int menor_nokia = 0;
int posicion_menor = 0;
for (int i = 0; i < clientes.length; i++) {
clientes[i] = new Cliente();
System.out.println("Escoja celular:n1.-Nokian2.-Motorola" + "n3.-LGn4.-Kyocera");
opc=Integer.parseInt(in.readLine());
switch(opc){
case 1:
String marcaCelular= "Nokia";
System.out.println("Ingrese nombre del cliente");
String nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
int cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
int precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
this is my tried but i fail. always print the firs position of the array, i dont know why if posicion_menor is in the condition if, so should give me the position of clientes in the array.
if(menor_nokia>precioCelular){
menor_nokia=precioCelular;
posicion_menor=i;
}
break;
case 2:
marcaCelular = "Motorola";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
break;
case 3:
marcaCelular = "LG";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
ventasLG++;
break;
case 4:
marcaCelular = "Kyocera";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
if (precioCelular >= 300000) {
ventasKyocera++;
}
break;
default:
System.out.println("Opcion incorrecta");
}
}
System.out.println("La cedula con menor precio en nokia es: "+ clientes[posicion_menor].getCedulaIdentidad());
for (Cliente clint : clientes) {
//1
if (clint.getMarcaCelular().equals("Motorola")) {
System.out.println("Nombre del primer cliente en comprar un motorola: "+clint.getNombreCliente()
+ "nCedula del primer cliente en comprar un motorola: " + clint.getCedulaIdentidad());
}//4
if(clint.getPrecioCelular()>500000){
System.out.println("Marca del primer cliente en superar"
+ "los $500000: "+clint.getMarcaCelular());
break;
}
}
//2
double porcentajeLG = (ventasLG*100)/4;
System.out.println("El porcentaje de LG vendidos es: "+porcentajeLG+"%");
//3
System.out.println("Se vendieron "+ventasKyocera+" celulares Kyocera");
}
}
java
add a comment |
i have a array of clientes who have a nombre, cedulaIdentidad, marcaCelular y precioCelular. and i have four opcion of telephone, nokia, motorola, lg and kyocera. i need find cedulaIdentidad of the client that buy a nokia at the lowe price. thanks for the help.
package recursos;
public class Cliente {
private String nombreCliente;
private int cedulaIdentidad;
private int precioCelular;
private String marcaCelular;
public Cliente(String nombre, int cedulaIdentidad, String marcaCelular, int precioCelular){
this.nombreCliente=nombre;
this.cedulaIdentidad=cedulaIdentidad;
this.precioCelular=precioCelular;
this.marcaCelular=marcaCelular;
}
public Cliente() {
}
public String getNombreCliente() {
return nombreCliente;
}
public int getCedulaIdentidad() {
return cedulaIdentidad;
}
public int getPrecioCelular() {
return precioCelular;
}
public void setPrecioCelular(int precioCelular) {
this.precioCelular = precioCelular;
}
public void setNombreCliente(String nombreCliente) {
this.nombreCliente = nombreCliente;
}
public void setCedulaIdentidad(int cedulaIdentidad) {
this.cedulaIdentidad = cedulaIdentidad;
}
public String getMarcaCelular() {
return marcaCelular;
}
public void setMarcaCelular(String marcaCelular) {
this.marcaCelular = marcaCelular;
}
}
package principal1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import recursos.Cliente;
public class Principal1 {
public static void main(String args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Cliente clientes = new Cliente[4];
int opc = 0;
int ventasLG = 0;
int ventasKyocera = 0;
int menor_nokia = 0;
int posicion_menor = 0;
for (int i = 0; i < clientes.length; i++) {
clientes[i] = new Cliente();
System.out.println("Escoja celular:n1.-Nokian2.-Motorola" + "n3.-LGn4.-Kyocera");
opc=Integer.parseInt(in.readLine());
switch(opc){
case 1:
String marcaCelular= "Nokia";
System.out.println("Ingrese nombre del cliente");
String nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
int cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
int precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
this is my tried but i fail. always print the firs position of the array, i dont know why if posicion_menor is in the condition if, so should give me the position of clientes in the array.
if(menor_nokia>precioCelular){
menor_nokia=precioCelular;
posicion_menor=i;
}
break;
case 2:
marcaCelular = "Motorola";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
break;
case 3:
marcaCelular = "LG";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
ventasLG++;
break;
case 4:
marcaCelular = "Kyocera";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
if (precioCelular >= 300000) {
ventasKyocera++;
}
break;
default:
System.out.println("Opcion incorrecta");
}
}
System.out.println("La cedula con menor precio en nokia es: "+ clientes[posicion_menor].getCedulaIdentidad());
for (Cliente clint : clientes) {
//1
if (clint.getMarcaCelular().equals("Motorola")) {
System.out.println("Nombre del primer cliente en comprar un motorola: "+clint.getNombreCliente()
+ "nCedula del primer cliente en comprar un motorola: " + clint.getCedulaIdentidad());
}//4
if(clint.getPrecioCelular()>500000){
System.out.println("Marca del primer cliente en superar"
+ "los $500000: "+clint.getMarcaCelular());
break;
}
}
//2
double porcentajeLG = (ventasLG*100)/4;
System.out.println("El porcentaje de LG vendidos es: "+porcentajeLG+"%");
//3
System.out.println("Se vendieron "+ventasKyocera+" celulares Kyocera");
}
}
java
add a comment |
i have a array of clientes who have a nombre, cedulaIdentidad, marcaCelular y precioCelular. and i have four opcion of telephone, nokia, motorola, lg and kyocera. i need find cedulaIdentidad of the client that buy a nokia at the lowe price. thanks for the help.
package recursos;
public class Cliente {
private String nombreCliente;
private int cedulaIdentidad;
private int precioCelular;
private String marcaCelular;
public Cliente(String nombre, int cedulaIdentidad, String marcaCelular, int precioCelular){
this.nombreCliente=nombre;
this.cedulaIdentidad=cedulaIdentidad;
this.precioCelular=precioCelular;
this.marcaCelular=marcaCelular;
}
public Cliente() {
}
public String getNombreCliente() {
return nombreCliente;
}
public int getCedulaIdentidad() {
return cedulaIdentidad;
}
public int getPrecioCelular() {
return precioCelular;
}
public void setPrecioCelular(int precioCelular) {
this.precioCelular = precioCelular;
}
public void setNombreCliente(String nombreCliente) {
this.nombreCliente = nombreCliente;
}
public void setCedulaIdentidad(int cedulaIdentidad) {
this.cedulaIdentidad = cedulaIdentidad;
}
public String getMarcaCelular() {
return marcaCelular;
}
public void setMarcaCelular(String marcaCelular) {
this.marcaCelular = marcaCelular;
}
}
package principal1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import recursos.Cliente;
public class Principal1 {
public static void main(String args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Cliente clientes = new Cliente[4];
int opc = 0;
int ventasLG = 0;
int ventasKyocera = 0;
int menor_nokia = 0;
int posicion_menor = 0;
for (int i = 0; i < clientes.length; i++) {
clientes[i] = new Cliente();
System.out.println("Escoja celular:n1.-Nokian2.-Motorola" + "n3.-LGn4.-Kyocera");
opc=Integer.parseInt(in.readLine());
switch(opc){
case 1:
String marcaCelular= "Nokia";
System.out.println("Ingrese nombre del cliente");
String nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
int cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
int precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
this is my tried but i fail. always print the firs position of the array, i dont know why if posicion_menor is in the condition if, so should give me the position of clientes in the array.
if(menor_nokia>precioCelular){
menor_nokia=precioCelular;
posicion_menor=i;
}
break;
case 2:
marcaCelular = "Motorola";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
break;
case 3:
marcaCelular = "LG";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
ventasLG++;
break;
case 4:
marcaCelular = "Kyocera";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
if (precioCelular >= 300000) {
ventasKyocera++;
}
break;
default:
System.out.println("Opcion incorrecta");
}
}
System.out.println("La cedula con menor precio en nokia es: "+ clientes[posicion_menor].getCedulaIdentidad());
for (Cliente clint : clientes) {
//1
if (clint.getMarcaCelular().equals("Motorola")) {
System.out.println("Nombre del primer cliente en comprar un motorola: "+clint.getNombreCliente()
+ "nCedula del primer cliente en comprar un motorola: " + clint.getCedulaIdentidad());
}//4
if(clint.getPrecioCelular()>500000){
System.out.println("Marca del primer cliente en superar"
+ "los $500000: "+clint.getMarcaCelular());
break;
}
}
//2
double porcentajeLG = (ventasLG*100)/4;
System.out.println("El porcentaje de LG vendidos es: "+porcentajeLG+"%");
//3
System.out.println("Se vendieron "+ventasKyocera+" celulares Kyocera");
}
}
java
i have a array of clientes who have a nombre, cedulaIdentidad, marcaCelular y precioCelular. and i have four opcion of telephone, nokia, motorola, lg and kyocera. i need find cedulaIdentidad of the client that buy a nokia at the lowe price. thanks for the help.
package recursos;
public class Cliente {
private String nombreCliente;
private int cedulaIdentidad;
private int precioCelular;
private String marcaCelular;
public Cliente(String nombre, int cedulaIdentidad, String marcaCelular, int precioCelular){
this.nombreCliente=nombre;
this.cedulaIdentidad=cedulaIdentidad;
this.precioCelular=precioCelular;
this.marcaCelular=marcaCelular;
}
public Cliente() {
}
public String getNombreCliente() {
return nombreCliente;
}
public int getCedulaIdentidad() {
return cedulaIdentidad;
}
public int getPrecioCelular() {
return precioCelular;
}
public void setPrecioCelular(int precioCelular) {
this.precioCelular = precioCelular;
}
public void setNombreCliente(String nombreCliente) {
this.nombreCliente = nombreCliente;
}
public void setCedulaIdentidad(int cedulaIdentidad) {
this.cedulaIdentidad = cedulaIdentidad;
}
public String getMarcaCelular() {
return marcaCelular;
}
public void setMarcaCelular(String marcaCelular) {
this.marcaCelular = marcaCelular;
}
}
package principal1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import recursos.Cliente;
public class Principal1 {
public static void main(String args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Cliente clientes = new Cliente[4];
int opc = 0;
int ventasLG = 0;
int ventasKyocera = 0;
int menor_nokia = 0;
int posicion_menor = 0;
for (int i = 0; i < clientes.length; i++) {
clientes[i] = new Cliente();
System.out.println("Escoja celular:n1.-Nokian2.-Motorola" + "n3.-LGn4.-Kyocera");
opc=Integer.parseInt(in.readLine());
switch(opc){
case 1:
String marcaCelular= "Nokia";
System.out.println("Ingrese nombre del cliente");
String nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
int cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
int precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
this is my tried but i fail. always print the firs position of the array, i dont know why if posicion_menor is in the condition if, so should give me the position of clientes in the array.
if(menor_nokia>precioCelular){
menor_nokia=precioCelular;
posicion_menor=i;
}
break;
case 2:
marcaCelular = "Motorola";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
break;
case 3:
marcaCelular = "LG";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
ventasLG++;
break;
case 4:
marcaCelular = "Kyocera";
System.out.println("Ingrese nombre del cliente");
nombre = in.readLine();
System.out.println("Ingrese cedula de identidad");
cedulaIdentidad = Integer.parseInt(in.readLine());
System.out.println("Ingrese precio del celular");
precioCelular = Integer.parseInt(in.readLine());
clientes[i] = new Cliente(nombre, cedulaIdentidad, marcaCelular, precioCelular);
if (precioCelular >= 300000) {
ventasKyocera++;
}
break;
default:
System.out.println("Opcion incorrecta");
}
}
System.out.println("La cedula con menor precio en nokia es: "+ clientes[posicion_menor].getCedulaIdentidad());
for (Cliente clint : clientes) {
//1
if (clint.getMarcaCelular().equals("Motorola")) {
System.out.println("Nombre del primer cliente en comprar un motorola: "+clint.getNombreCliente()
+ "nCedula del primer cliente en comprar un motorola: " + clint.getCedulaIdentidad());
}//4
if(clint.getPrecioCelular()>500000){
System.out.println("Marca del primer cliente en superar"
+ "los $500000: "+clint.getMarcaCelular());
break;
}
}
//2
double porcentajeLG = (ventasLG*100)/4;
System.out.println("El porcentaje de LG vendidos es: "+porcentajeLG+"%");
//3
System.out.println("Se vendieron "+ventasKyocera+" celulares Kyocera");
}
}
java
java
asked Nov 20 '18 at 3:16
carpoppercarpopper
45
45
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385693%2fi-need-find-cedulaidentidad-of-clientes-array-that-buy-a-nokia-at-a-lower-price%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385693%2fi-need-find-cedulaidentidad-of-clientes-array-that-buy-a-nokia-at-a-lower-price%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown