-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
60 lines (60 loc) · 3.32 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
setwd("C:/Shashank/Trainings/DS-Refresher")
source('C:/Shashank/Trainings/DS-Refresher/Assignment-03-Solution.r')
source('Assignment-03-Solution.r')
# DS-Refresher Assignment - 3
cat('\n', '=============================================', '\n')
print('DS-Refresher')
print('Assignment - 3')
cat('\n', '=============================================', '\n')
# Question 1
cat('\n', '=============================================', '\n')
print('1. Write a program to read Celsius temperature and print equivalent Fahrenheit temperate on screen using R.')
temp_c = as.numeric(readline('Enter Temperature in Celsius: '))
print(sprintf('Equivalent Temperature in Fahrenheit is %.2f', temp_f))
cat('\n', '=============================================', '\n')
# Question 2
cat('\n', '=============================================', '\n')
print('2. Read radius of the circle from user and find the area and perimeter of it using R.')
pi = 3.14
radius = as.numeric(readline('Enter radius of the circle: '))
circumference = 2*pi*radius
print(sprintf('Area of circle with radius %.2f is %.2f and it\'s circumference is %.2f', radius, area, circumference))
cat('\n', '=============================================', '\n')
# Question 3
cat('\n', '=============================================', '\n')
print('3. Read the amount and percentage of interest from the keyboard and find final amount after adding interest in original amount using R.')
principal = as.numeric(readline('Enter principal amount: '))
final_amt = principal*(1 + interest/100)
print(sprintf('Final amount is %.2f', final_amt))
cat('\n', '=============================================', '\n')
# Question 4
cat('\n', '=============================================', '\n')
print('4. Write a program to read distance value in meters and convert it into centimeters, inches, and yards using R.')
dist_mt = as.numeric(readline('Enter distance in meters: '))
dist_in = dist_mt*39.3701
source('C:/Shashank/Trainings/DS-Refresher/Assignment-03-Solution.r')
dist_yd = dist_mt*1.09361
# DS-Refresher Assignment - 3
cat('\n', '=============================================', '\n')
print('DS-Refresher')
print('Assignment - 3')
cat('\n', '=============================================', '\n')
# Question 1
cat('\n', '=============================================', '\n')
print('1. Write a program to read Celsius temperature and print equivalent Fahrenheit temperate on screen using R.')
temp_c = as.numeric(readline('Enter Temperature in Celsius: '))
temp_f = temp_c*9/5 + 32
print(sprintf('Equivalent Temperature in Fahrenheit is %.2f', temp_f))
cat('\n', '=============================================', '\n')
# Question 2
cat('\n', '=============================================', '\n')
print('2. Read radius of the circle from user and find the area and perimeter of it using R.')
pi = 3.14
radius = as.numeric(readline('Enter radius of the circle: '))
area = pi*radius*radius
circumference = 2*pi*radius
print(sprintf('Area of circle with radius %.2f is %.2f and it\'s circumference is %.2f', radius, area, circumference))
cat('\n', '=============================================', '\n')
# Question 3
cat('\n', '=============================================', '\n')
print('3. Read the amount and percentage of interest from the keyboard and find final amount after adding interest in original amount using R.')