You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
11 Hrs
52 Min
4 Seg

Desarrollo del proyecto - Parte 1

17/19
Resources

How to create an interactive application with artificial intelligence?

In this lesson, we will explore the use of artificial intelligence to create an application that suggests the final price of a product and calculates the profit margin, integrating advanced technology in a coherent and responsible manner. You will learn how to use a text editor with AI technology to facilitate your work as a developer - it's a great way to boost your skills!

What is the goal of the project?

The goal of our project is to develop an application that not only calculates the final price of a product by considering the cost of raw materials, profit margins, and taxes, but also asks the user how many sales he expects to make in order to calculate the profit margin. All this will be executed via console and with the use of JavaScript.

How is the application developed in JavaScript?

  1. Initial interaction with artificial intelligence: A sidebar is activated in the text editor to give instructions to the AI assistant. It is asked to create the application using JavaScript and to be executed via console.

  2. Script development: Once the request is detailed, a script titled calculate_price.js is generated. This script:

    • Uses the Redline module to handle console input and output.
    • Defines a function to calculate the final price based on the provided costs and margins.
    • Calculates the expected total profit based on the user's projected sales.

JavaScript Script Code:

// The proposed code to calculate the final price of a product and ask for projected sales
const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout});
function calculateFinalPrice(rawMaterialCost, ProfitMargin, TaxRate) { return rawMaterialCost + (rawMaterialCost * ProfitMargin) + (rawMaterialCost * TaxRate);
}
function calculateTotalProfit(endPrice, quantitySales, costCostPrimeMaterial) { return (endPrice - costCostPrimeMaterial) * quantitySales;}
readline.question('Enter the raw material cost: ', (cost) => { readline.question('Enter the profit margin in decimal (e.g. 0.3 for 30%): ', (margin) => { readline.question('Enter the tax rate in decimal: ', (tax) => { const priceFinal = calculatePriceFinal(parseFloat(cost), parseFloat(margin), parseFloat(tax)); console.log(`Thesuggested final price is: ${priceFinal}`);
 readline.question('How many sales of the product do you expect to make? ', (sales) => { const profitTotal = calculateProfitTotal(priceFinal, parseFloat(sales), parseFloat(cost)); console.log(`Theexpected total profit is: ${profitTotal}`); readline.close(); }); }); }); }); });

How to validate the logic of the generated code?

It is vital to validate the logic of the suggested code before implementing it in a production environment. Although IA makes it easy to create code, the developer must understand and verify each segment to ensure that it conforms to the defined requirements and standards.

How to integrate a graphical interface with JavaScript?

The next step is to enrich our project by using a graphical user interface (GUI) instead of console interaction.

  1. Frontend generation with AI: The AI wizard is asked to generate an interface using HTML, CSS and JavaScript.
  2. Project Structure: The wizard proposes and creates the necessary files: index.html for the base structure, styles.css for the visual design and script.js for the logic.

HTML and CSS code snippet

<!-- index.html --><!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="styles.css"> <title>PriceCalculator</title></head><body><body> <div class="container"> <h1>PriceCalculator</h1> <!-- Inputs and Buttons here --> </div> <script src="script.js"></script></body></html></html>
/* styles.css */body { font-family: Arial, sans-serif; background-color: #f0f0f0;} }
.container { max-width: 400px; margin: 50px auto; padding: 20px; background-color: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0, 0.1);}

Why is it important to integrate AI responsibly?

Responsible use of artificial intelligence in development involves:

  • Complete understanding: Before implementing any suggested code, make sure it aligns with the planned logic.
  • Adaptability: Make sure AI tools serve your needs without deviating from the project schedule.
  • Collaboration and learning: By adopting AI, you foster an environment where humans and machines collaborate to increase efficiency without sacrificing quality.

This approach not only improves your level as a developer, but also prepares you to face the challenges of a constantly evolving job market.

Contributions 14

Questions 1

Sort by:

Want to see more contributions, questions and answers from the community?

![](https://static.platzi.com/media/user_upload/Screenshot%202024-11-14%20at%2012.13.51PM-be94642b-e1cc-4b01-8590-7ff57bd33efb.jpg)aqui el resultado, el asistente lo creo usando flask para el codigo python y html css y js para el front.
![](https://static.platzi.com/media/user_upload/Screenshot%202024-11-14%20at%2012.03.40PM-e87d322a-4783-4533-bd81-51ff20a5cc6d.jpg)lo hice en python y funciono a la primera.
隆Increible! Pude crear la aplicaci贸n a la primera, le indique que usara **dart y flutter**, el resultado me dej贸 sorprendido. Funcion贸 sin problemas en dos entornos diferentes (un emulador Android y como aplicaci贸n web en Chrome) ![](https://static.platzi.com/media/user_upload/image-9dc89e39-a4f1-4f7d-bd21-29db25ae2c25.jpg)
Excelente herramienta y excelente curso! ![](https://static.platzi.com/media/user_upload/Screenshot%202024-11-19%20at%203.21.19PM-86518d91-8fb8-4bf7-8136-88b871e05be4.jpg)
**NUESTRO CONOCIMIENTO:** Hacemos un plan, pensamos casos de uso, en ese momento definimos una l贸gica y planteamos de forma completa nuestra necesidad. **SKILL NECESARIO:** Aplicar nuestro criterio, **la AI es un apoyo**, la usamos responsablemente cuando tenemos en cuenta las buenas pr谩cticas, y adaptamos la AI a nuestras necesidades (no al rev茅s).
![](https://static.platzi.com/media/user_upload/image-1d7187d9-69ec-427a-8ce6-2dd80914d783.jpg)
git hub copilot acaba de liberar la beta de agente para desarrollo, ahora ya lleg贸 a la altura de cursor, por otro lado el ide TRAE.AI hace muchas cosas que hace cursor, pero es gratuito. este curso es muy interesante
El c贸digo generado por Cursor AI es solo un punto de partida. Es crucial que lo analices, comprendas su l贸gica y lo adaptes a tus necesidades espec铆ficas antes de implementarlo. Esto asegura que el c贸digo no solo funcione, sino que tambi茅n se ajuste a las mejores pr谩cticas y a la planificaci贸n de tu proyecto. La inteligencia artificial es una herramienta que complementa tu trabajo, pero la responsabilidad de la calidad del c贸digo recae en ti como desarrollador.
Le adicione un SweetAlert con opcion de descargar los resultados en un documento txt. ![](https://static.platzi.com/media/user_upload/image-be32a375-edd4-4df0-8a31-e61923373880.jpg)![](https://static.platzi.com/media/user_upload/image-3a766f7a-72dd-440a-b9d6-901a6986f37b.jpg)
a mi me creo el css dentro del html. ![](https://static.platzi.com/media/user_upload/image-b88f881a-fca0-40cf-9a8f-f1a89bf2ca82.jpg)
Nose si fue por la palabra aplicaci贸n pero fue la unica IA que importo lo necesario para que no explotara.
Una de las estrategias que uso para tener un r谩pido entendimiento del c贸digo generado, lo que hago es darle el pront de que comente las l铆neas de c贸digo de manera corta y precisa
dejo a mano los prompts: 1- ayudame a crear una aplicaci贸n que calcule y sugiera el precio final de un producto tomando en cuenta el costo de la materia prima, margen de ganancia e impuestos. Una vez calculado y mostrado, le pregunta al usuario por consola cu谩ntas ventas del producto espera realizar y despu茅s calcula y muestra el margen de ganancia. Todo el script lo quiero hacer 煤nicamente con JavaScript \================= 2- Ahora no quiero que la interacci贸n suceda por consola, sino que tengamos una interfaz gr谩fica que permita ingresar los datos e interactuar con la misma l贸gica de mi aplicaci贸n
Haciendo uso de la herramienta, esta me dio toda la estructura de un proyecto directamente haciendo uso de Electron para el Front y la interacci贸n. El resultado es sorpresivo: ![](https://static.platzi.com/media/user_upload/image-01ca5b11-8c27-4acb-b0ec-3b9e0bf4e29b.jpg)