💻 Dado la duración (en minutos) de una llamada telefónica, calcular su costo, de la siguiente manera: Hasta 5 min el costo es 0.90. Por encima de 5 min el, costo es 0.90+0.20 por cada minuto adicional a los 5 primeros min.
Para este ejercicio tomamos en cuenta que para llamadas de hasta 5 minutos, multiplicaremos el valor por 0.90; en caso de ser mayor de 5 minutos multiplicamos los primeros 5 * 0.9 y los restantes por 1.1 que es la suma de (0.90 + 0.20), de esa manera sólo aplicamos el costo para conocer el valor de la llamada telefónica.
ANÁLISIS DEL CÓDIGO
Para este ejercicio tomamos en cuenta que para llamadas de hasta 5 minutos, multiplicaremos el valor por 0.90; en caso de ser mayor de 5 minutos multiplicamos
los primeros 5 * 0.9 y los restantes por 1.1 que es la suma de (0.90 + 0.20).
VARIABLES ENTRADA :
Llamada = Guarda la cantidad de minutos.
INGRESO : Se ingresa la cantidad de minutos.
PROCESO : Se calcula el tiempo multiplicando por 0.9 hasta 5min y (0.9 + 0.20) si es más de 5min; ya que se le agrega 0.20 por encima de los 5min.
SALIDA : Muestra el costo a pagar.
Algoritmo programacion_work
Definir Llamada como Entero;
Escribir "CALCULAR EL COSTO DE UNA LLAMADA TELEFÓNICA.";
Escribir " ";
Escribir Sin Saltar "Ingrese los Minutos de su Llamada : ";
Leer Llamada;
Escribir "";
Si (Llamada <= 5) Entonces
Escribir "COSTO POR LLAMADA ES : $", Llamada * 0.9;
SiNo
Escribir "COSTO POR LLAMADA ES : $", (5*0.9)+((Llamada - 5)*1.1);
FinSi
FinAlgoritmo
print("CALCULAR EL COSTO DE UNA LLAMADA TELEFÓNICA.")
llamada = int(input("Ingrese los Minutos de su Llamada : "))
if (llamada <= 5):
print("COSTO POR LLAMADA ES : ",llamada*0.9)
else:
print("COSTO POR LLAMADA ES : ",(5*0.9)+((llamada-5)*1.1))
#include<stdio.h>
int main() {
int llamada;
printf("CALCULAR EL COSTO DE UNA LLAMADA.\n\n");
printf("Ingrese los minutos de su llamada : ");
scanf("%i",&llamada);
if (llamada <= 5) {
printf("\nCOSTO POR LLAMADA ES : $%.2f\n",llamada*0.9);
} else {
printf("\nCOSTO POR LLAMADA ES : $%.2f\n",(5*0.9)+((llamada-5)*1.1));
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
int llamada;
cout << "CALCULAR EL COSTO DE UNA LLAMADA.\n\n";
cout << "Ingrese los minutos de su llamada : ";
cin << llamada;
cout << endl;
if (llamada <= 5) {
cout << "COSTO POR LLAMADA ES : $" << llamada*0.9 << endl;
} else {
cout << "COSTO POR LLAMADA ES : $" << (5*0.9)+((llamada-5)*1.1) << endl;
}
return 0;
}
using System;
using System.Collections.Generic;
using System.Text;
namespace programacion_work
{
class costo_llamada
{
static void Main(string[] args)
{
int llamada;
Console.WriteLine("CALCULAR EL COSTO DE UNA LLAMADA.\n");
Console.Write("Ingrese los minutos de su llamada : ");
llamada = int.Parse(Console.ReadLine());
if (llamada <= 5)
{
Console.WriteLine("\nCOSTO POR LLAMADA ES : $" + String.Format("{0,4:##.00}",llamada * 0.9));
}
else
{
Console.WriteLine("\nCOSTO POR LLAMADA ES : $" + String.Format("{0,4:##.00}",(5 * 0.9) + ((llamada - 5) * 1.1)));
}
Console.ReadLine();
}
}
}
package programacion_work;
import java.util.Scanner;
public class costo_llamada {
public static void main(String[] args) {
Scanner ingreso=new Scanner(System.in);
int llamada;
System.out.print("COSTO DE UNA LLAMADA TELEFÓNICA.\n\n");
System.out.print("Ingrese los minutos de su llamada : ");
llamada = Integer.parseInt(ingreso.next());
if(llamada <= 5){
System.out.println("COSTO DE LLAMADA : " + (llamada * 0.9));
}else{
System.out.println("COSTO DE LLAMADA : " + ((5*0.9)+((llamada-5)*1.1)));
}
}
}
package programacion_work;
import java.text.DecimalFormat;
private void jBtn_CalcularActionPerformed(java.awt.event.ActionEvent evt) {
int llamada;
DecimalFormat df = new DecimalFormat("#.00");
llamada = Integer.parseInt(jTxt_cant.getText());
if(llamada <= 5){
jTxt_Costo.setText( df.format(llamada * 0.9) );
}else{
jTxt_Costo.setText( df.format((5 * 0.9) + ((llamada - 5)*1.1)) );
}
}
Imports System.Console
Module costo_llamada
Dim Llamada As Integer
Sub Main()
WriteLine("OBTENER EL COSTO DE UNA LLAMADA TELEFÓNICA.")
WriteLine("")
Write("Igrese Tiempo de Duración de la llamada : ")
Llamada = ReadLine()
WriteLine("")
If (Llamada <= 5) Then
WriteLine("El Costo de la llamada es : " & Llamada * 0.9)
Else
WriteLine("El Costo de la llamada es : " & (5 * 0.9) + ((Llamada - 5) * 1.1))
End If
ReadLine()
End Sub
End Module
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Llamada As Integer
Llamada = Txt_Min.Text
If (Llamada <= 5) Then
Lbl_msg.Text = "El Costo de la llamada es : " & (Llamada * 0.9)
Else
Lbl_msg.Text = "El Costo de la llamada es : " & ((5 * 0.9) + ((Llamada - 5) * 1.1))
End If
End Sub
Sub Llamada()
Dim Llamada As Integer
Llamada = Range("D12").Value
If (Llamada <= 5) Then
Range("G12").Value = Llamada * 0.9
Else
Range("G12").Value = (5 * 0.9) + ((Llamada - 5) * 1.1)
End If
End Sub
Sub llamada2()
Dim Llamada As Integer
Llamada = InputBox("INGRESE TIEMPO EN MIN.")
If (Llamada <= 5) Then
MsgBox "COSTO DE LA LLAMADA : " & Llamada * 0.9
Else
MsgBox "COSTO DE LA LLAMADA : " & (5 * 0.9) + ((Llamada - 5) * 1.1)
End If
End Sub
Private Sub btn_calcular_Click()
Dim Llamada As Integer
Llamada = txt_llamada.Text
If (Llamada <= 5) Then
txt_result.Text = Llamada * 0.9
Else
txt_result.Text = (5 * 0.9) + ((Llamada - 5) * 1.1)
End If
End Sub