Sunteți pe pagina 1din 2

PRACTICE

 PROBLEMS  (CONTROL  STRUCTURES)  

1) Ask  the  user  for  the  following  input:  Exam  1  score,  Exam  2  Score,  Exam  3  Score,  
Finals  Score.  Your  program  should  compute  the  final  grade  of  the  student  based  
on  the  following  formula:  
 
Final  Grade  =  0.7  x  (Average  of  3  Exams)  +  0.3  x  Finals  Score.  
 
Afterwards,  assign  to  it  the  equivalent  grade  from  the  grading  scale  in  our  
syllabus(e.g.  1.00,  1.75,  3.00)  based  on  the  computed  final  grade.    Display  the  
Final  Grade  and  the  equivalent  grade.  Make  sure  that  the  value  for  the  exams  and  
finals  score  is  between  0  and  100.  The  value  for  the  exams  and  finals  score  may  
have  decimal  places  (e.g.  97.2,  6.92)    
 
Sample  Run:  
Enter  Exam  1  Score>  50  
Enter  Exam  2  Score>  70  
Enter  Exam  3  Score>  90  
Enter  Finals  Score>  100  
 
Your  Final  Grade  is  79.0.  
Your  Equivalent  Grade  is  2.00.  
 
2) Ask  the  user  for  two  integer  inputs.  Your  program  should  check  if  the  two  
integers  are  relatively  prime  or  not.  Two  integers  are  relatively  prime  if  they  do  
not  share  a  common  divisor  other  than  1.  Make  sure  that  the  inputs  are  positive,  
nonzero  integers.  
 
Sample  Run  1:  
Enter  a  number>  56  
Enter  another  number>  10  
 
56  and  10  are  NOT  relatively  prime.  
 
Sample  Run  2:  
Enter  a  number>  50  
Enter  another  number>  17  
 
50  and  17  are  relatively  prime.  
 
3) Ask  the  user  for  an  integer  input.  Your  program  should  output  the  English  word  
equivalent  of  the  number  input.  Make  sure  that  the  input  is  an  integer  between  0  
to  100,  including  0  and  100.  
 
Sample  Run  1:  
 
Enter  a  number>  51  
 
FIFTY  ONE  
 
 
 
 
 
Sample  Run  2:  
 
Enter  a  number>  30  
 
THIRTY  
 
 
Sample  Run  3:  
 
Enter  a  number>  100  
 
ONE  HUNDRED  
 
4) Ask  the  user  for  two  character  inputs.  Make  sure  that  the  input  is  a  letter  from  
the  English  alphabet.  You  are  to  check  how  far  away  the  first  letter  input  is  from  
the  second.  For  example,  ‘a’  is  one  unit  away  from  ‘b’.  If  the  two  character  inputs  
are  the  same,  say    ‘c’  and  ‘c’,  then  they  are  zero  units  away  from  each  other.  As  a  
challenge,  the  small  and  big  cap  form  of  a  letter  should  be  treated  the  same,  so  ‘d’  
and  ‘D’  are  zero  units  away  from  each  other.  
 
Sample  Run  1:  
 
Enter  a  letter>  c  
Enter  another  letter>  y  
 
c  is  22  units  away  from  y  
 
Sample  Run  2:  
 
Enter  a  letter>  j  
Enter  another  letter>  e  
 
j  is  7  units  away  from  e  
 
 
 

S-ar putea să vă placă și