Advertisement
gtw7375

SCRIPTLETS - JAVA

Apr 8th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.94 KB | None | 0 0
  1. package bemvindo;
  2.  
  3. public class Cliente {
  4.    
  5.     private String nome, sobrenome;
  6.     private double montante;
  7.    
  8.     public Cliente(String nome, String sobrenome, double montante){
  9.        
  10.         this.nome = nome;
  11.         this.sobrenome = sobrenome;
  12.         this.montante = montante;      
  13.     }
  14.    
  15.     public String nomes(){
  16.        
  17.         return this.nome + " " + this.sobrenome;
  18.        
  19.     }
  20.    
  21.     public double getmontate(){
  22.        
  23.         return this.montante;
  24.        
  25.     }
  26. }
  27.  
  28. ------------------------------------------------------------------------------
  29.  
  30.                 INDEX.JSP
  31.  
  32.  
  33. <%@page import="bemvindo.Cliente" %>
  34. <%@page import="java.util.Date"%>
  35. <%@page import="java.text.SimpleDateFormat" %>
  36. <%@ page language="java" contentType="text/html; charset=UTF-8"
  37.     pageEncoding="UTF-8"%>
  38. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  39. <html>
  40. <head>
  41. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  42. <title>Insert title here</title>
  43. </head>
  44. <body>
  45.  
  46.     <%  
  47.         SimpleDateFormat dia = new SimpleDateFormat("dd/MM/yyyy");
  48.         Date diaAtual = new Date();
  49.         String strDia = dia.format(diaAtual);%>
  50.        
  51.         <label> Hora: </label>  <%=diaAtual %>
  52.  
  53. <br><br><br><br><br>
  54.  
  55. <h2> EXERCÍCIO TWO </h2>
  56.  
  57. <%
  58. Cliente[] clt = new Cliente[3];
  59. clt[0] = new Cliente("Luiz", "Santos", 2000.00);
  60. clt[1] = new Cliente("Luis", "Xantox", 12000.00);
  61. clt[2] = new Cliente("Lhuizx", "SXanthos", 6000.00);
  62. double totalMontante = 0, montante = 0;
  63. %>
  64.  
  65. <table>
  66.     <tr><td coslpan="3"><hr></td></tr>
  67.     <tr><td coslpan="3" align="center"><strong>Relatorio</strong></td></tr>
  68.     <tr><td coslpan="3"><hr></td></tr>
  69.    
  70.     <tr><td>#</td><td>Nome:</td><td>Vendas:<i>($)</i></td>
  71.     <tr><td colspan="3"><hr></td></tr>
  72.  
  73.  
  74. <%
  75. for(int i=0; i<clt.length; i++){
  76.     totalMontante = clt[i].getmontate();
  77.     totalMontante += montante;
  78.  
  79. %>
  80.  
  81. <tr>
  82.     <td> <%= (i+1) %></td>
  83.     <td> <%= clt[i].nomes() %></td>
  84.     <td align="right"><%= montante %></td>
  85. </tr>
  86.  
  87. <% } %>
  88.  
  89. <tr><td colspan="3"><hr></ht></td>
  90.  
  91. <tr>
  92.     <td colspan="3" align="right"><strong>Total:</strong></td>
  93.     <td align="right"><strong><%=totalMontante%></strong></td>
  94.     <td colspan="3"><hr></td></tr>
  95. ---------------------------------------------------------
  96.  
  97. controle.java
  98.  
  99. o;
  100.  
  101. public class controle {
  102.  
  103.     public double acumulador(){
  104.         double totalMontante=0;
  105.         return totalMontante;
  106.     }
  107.    
  108.     public double manipulaMontante(){
  109.         double montante=0;
  110.         return montante;
  111.     }
  112.    
  113.     public int  contador(){
  114.        
  115.         int i = i+1;
  116.         return i;
  117.        
  118.     }
  119.    
  120.     public void controle(){
  121.        
  122.                
  123.         Cliente[] clt = new Cliente[3];
  124.         clt[0] = new Cliente("Luiz", "Santos", 2000.00);
  125.         clt[1] = new Cliente("Luis", "Xantox", 12000.00);
  126.         clt[2] = new Cliente("Lhuizx", "SXanthos", 6000.00);
  127.         double totalMontante = 0, montante = 0;
  128.        
  129.         for(int i=0; i<clt.length; i++){
  130.             double mont = manipulaMontante();
  131.             mont = clt[i].getmontate();
  132.             double totMont = acumulador();
  133.             totMont +=mont;
  134.            
  135.     }
  136. }
  137.    
  138. }
  139.  
  140. </table>
  141. </body>
  142. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement