0% found this document useful (0 votes)
9 views3 pages

Bonus Calculation and Triangle Area Code

The document contains several code snippets for different calculations in R programming. It includes bonus calculations based on account balance and gender, area calculation of a triangle using its sides, conversion of days into months and remaining days, and summing the first and last digits of a number. Each snippet prompts the user for input and prints the result.

Uploaded by

rajarjun7070
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Bonus Calculation and Triangle Area Code

The document contains several code snippets for different calculations in R programming. It includes bonus calculations based on account balance and gender, area calculation of a triangle using its sides, conversion of days into months and remaining days, and summing the first and last digits of a number. Each snippet prompts the user for input and prints the result.

Uploaded by

rajarjun7070
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// bonus calculation

{
balance<-[Link](readline("Enter the balance value"))
sex<-readline("Enter the sex")
if(sex=="f")
{
if(balance>5000)
{
bonus<-balance*5%/%100
balance<-balance+bonus
print(paste("balance=",balance))
}
else
{
bonus<-balance*2%/%100
balance<-balance+bonus
print(paste("balance=",balance))
}
}
else
{
bonus<-balance*2%/%100
balance<-balance+bonus
print(paste("balance=",balance))
}
}
{
balance <- [Link](readline("Enter Account Balance: "))
gender <- readline("Enter Gender (M/F): ")

# Base bonus: everyone gets 2%


bonus <- balance * 0.02

# Nested IF for female additional bonus


if (gender == "F" || gender == "f") {

if (balance > 5000) {


bonus <- bonus + (balance * 0.05)
}

cat("Total Bonus Amount = Rs.", bonus, "\n")


}

//area of triangle
{
a<-[Link](readline("Enter the a value"))
b<-[Link](readline("Enter the a value"))
c<-[Link](readline("Enter the a value"))
s<-(a+b+c)/2
area<-(s*(s-a)*(s-b)*(s-c))
print(paste("side=",s))
print(paste("area=",area))
}
{
days<-[Link](readline("Enter the days"))
month<-days %/% 30
bdays<-days %% 30
print(paste("month=",month))
print(paste("bdays=",bdays))
}

// sum first and last


{
n=[Link](readline("Enter n value"))
first<-n%/%1000
last<-n%%10
sum=first+last
print(paste("sum=",sum))
}

You might also like