Last active
November 16, 2017 16:14
-
-
Save arxdsilva/9b1748f93da36a316d754e19cd8d4e61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.influenciadores; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.EditText; | |
public class InfluenciadoresActivity extends Activity { | |
EditText numProdutos, seguidoresPorInfluenciador; | |
EditText numTotalInfluenciadores, meta; | |
Button calcular; | |
EditText minPessCurtoPrazo, maxPessCurtoPrazo; | |
EditText medPessAtingidas, precoMin; | |
EditText precoMedio, metaAtingida; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_influenciadores); | |
numProdutos = (EditText) findViewById(R.id.editText1); | |
seguidoresPorInfluenciador = (EditText) findViewById(R.id.editText2); | |
numTotalInfluenciadores = (EditText) findViewById(R.id.editText3); | |
meta = (EditText) findViewById(R.id.EditText01); | |
minPessCurtoPrazo = (EditText) findViewById(R.id.EditText02); | |
maxPessCurtoPrazo = (EditText) findViewById(R.id.EditText03); | |
medPessAtingidas = (EditText) findViewById(R.id.EditText04); | |
precoMin = (EditText) findViewById(R.id.EditText05); | |
precoMedio = (EditText) findViewById(R.id.EditText06); | |
metaAtingida = (EditText) findViewById(R.id.EditText07); | |
calcular = (Button) findViewById(R.id.Button01); | |
calcular.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View arg0) { | |
int nProdutos, segPorInfluenciador; | |
int nTotalInfluenciadores, mta; | |
double minPessoasCP, maxPessoasCP; | |
double medPessoasA, pMin, pMed; | |
boolean mAtingida; | |
mAtingida = false; | |
nProdutos = Integer.parseInt(numProdutos.getText().toString()); | |
segPorInfluenciador = Integer.parseInt(seguidoresPorInfluenciador.getText().toString()); | |
nTotalInfluenciadores = Integer.parseInt(numTotalInfluenciadores.getText().toString()); | |
mta = Integer.parseInt(meta.getText().toString()); | |
minPessoasCP = (segPorInfluenciador * nTotalInfluenciadores) * 0.1; | |
maxPessoasCP = (segPorInfluenciador * nTotalInfluenciadores) * 0.5; | |
medPessoasA = (maxPessoasCP + minPessoasCP) / 2; | |
pMin = (nProdutos) * ((mta/1000)* 5.68); | |
pMed = (nProdutos) * ((medPessoasA/1000)* 5.68); | |
if (medPessoasA > mta) { | |
mAtingida = true; | |
} | |
minPessCurtoPrazo.setText(String.format("%1$.2f", minPessoasCP)); | |
maxPessCurtoPrazo.setText(String.format("%1$.2f", maxPessoasCP)); | |
medPessAtingidas.setText(String.format("%1$.2f", medPessoasA)); | |
precoMin.setText(String.format("%1$.2f", pMin)); | |
precoMedio.setText(String.format("%1$.2f", pMed)); | |
if (mAtingida) { | |
metaAtingida.setText("Sim"); | |
} else { | |
metaAtingida.setText("Não"); | |
} | |
} | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package influenciadores; | |
import java.util.Scanner; | |
public class Influenciadores { | |
public static void main(String[] args) { | |
String atingida; | |
Scanner scan = new Scanner(System.in); | |
System.out.print("numero de produtos: "); | |
int numProdutos = scan.nextInt(); | |
System.out.print("numero de seguidores por influenciador: "); | |
int seguidoresPorInfluenciador = scan.nextInt(); | |
System.out.print("numero de influenciadores: "); | |
int numInfluenciadores = scan.nextInt(); | |
System.out.print("meta de pessoas a ser atingida: "); | |
int meta = scan.nextInt(); | |
double minPessCP = (seguidoresPorInfluenciador * numInfluenciadores) * 0.1; | |
double maxPessCP = (seguidoresPorInfluenciador * numInfluenciadores) * 0.5; | |
double medPessoas = (maxPessCP + minPessCP)/2.0; | |
double precoMin = (numProdutos * (meta*5.68)/1000); | |
double precoMed = (numProdutos * (medPessoas*5.68)/1000); | |
if (medPessoas > meta) { | |
atingida = "sim"; | |
} else { | |
atingida = "não"; | |
} | |
System.out.printf("minimo de pessoas a curto prazo: %s%n",minPessCP); | |
System.out.printf("maximo de pessoas a curto prazo: %s%n",maxPessCP); | |
System.out.printf("media de pessoas atingidas: %s%n",medPessoas); | |
System.out.printf("preço minimo: %s%n",precoMin); | |
System.out.printf("preço medio: %s%n",precoMed); | |
System.out.printf("meta foi atingida? %s%n", atingida); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment