我已经完成了一半的代码,但我不确定如何做其余的代码需要紧急帮助 [英] i have done half of the codes but i am not sure how to do the rest need help urgent

查看:42
本文介绍了我已经完成了一半的代码,但我不确定如何做其余的代码需要紧急帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题1
长途电话提供商对电话收取以下费用:
费率类别每分钟费率
白天(6 am-5.59 pm)$ 0.07
傍晚(6 pm-11.59 pm)$ 0.12
非高峰期(12 am-5.59 am)$ 0.05
创建一个Java程序,该程序允许用户选择特定的费率类别(从一组
单选按钮),然后输入通话时间和分钟.将小时转换为分钟
以获取费用,然后以两位十进制的文本字段形式显示呼叫的费用
点.提示:使用DecimalFormat类.
参见图Q1作为输出屏幕.您不需要编写HTML文件.

必须显示在
小数点后两位

-------------------------------------------------- -----------------
我的一半答案:

QUESTION 1
A long-distance call provider charges the following rate for telephone calls:
Rate Category Rate per Minute
Daytime (6 am - 5.59 pm) $0.07
Evening (6 pm - 11.59 pm) $0.12
Off-Peak (12 am - 5.59 am) $0.05
Create a Java program that allows the user to select a specific rate category (from a set of
radio buttons), and enter hours and minutes of the call. Convert the hours to minutes in
order to get the charges and then display the charges for the call as a text field in twodecimal
points. Hint: Use DecimalFormat class.
Refer Figure Q1 as the output screen. You are not required to write the HTML file.

Must be displayed in
two decimal points

-------------------------------------------------------------------
my half answer :

import java.awt.*;
import javax.swing.*;

public class PYQMAY2010 extends JFrame
{
	private JLabel lb1, lb2, lb3, lb4;
	private JTextField tf1, tf2, tf3;
	private JRadioButton rb1, rb2, rb3;

public static void main(String []arg)
{
	PYQMAY2010 l = new PYQMAY2010();

	l.setSize(400,300);
	l.setVisible(true);
	l.setTitle("Applet Viewer: LongDistanceCalls");
	l.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

	public PYQMAY2010()
	{
		lb1 = new JLabel("Enter hours of the call:");
		lb2 = new JLabel("Enter minutes of the call:");
		lb3 = new JLabel("Rate category:");
		lb4 = new JLabel("Charges for the call :RM");
		tf1 = new JTextField(20);
		tf2 = new JTextField(20);
		tf3 = new JTextField(10);
		rb1 = new JRadioButton("Daytime (6 am - 5.59 am)");
		rb2 = new JRadioButton("Evening (6 pm - 11.59 pm)");
		rb3 = new JRadioButton("Off-Peck (12am - 5.59 am)");

		JPanel p1 = new JPanel();
		p1.setLayout(new GridLayout (2,1));
		p1.add(lb1);
		p1.add(tf1);
		p1.add(lb2);
		p1.add(tf2);

		JPanel p2 = new JPanel();
		p2.setLayout(new GridLayout(4,0));
		p2.add(lb3);
		p2.add(rb1);
		p2.add(rb2);
		p2.add(rb3);

		JPanel p3 = new JPanel();
		p3.setLayout(new FlowLayout(FlowLayout.CENTER));
		p3.add(lb4);
		p3.add(tf3);

		setLayout(new BorderLayout());
		add(p1,BorderLayout.NORTH);
		add(p2,BorderLayout.CENTER);
		add(p3,BorderLayout.SOUTH);
	}
}

推荐答案

0.07
晚上(6 pm-11.59 pm)
0.07
Evening (6 pm - 11.59 pm)


0.12
非高峰(上午12点-上午5.59)
0.12
Off-Peak (12 am - 5.59 am)


0.05
创建一个Java程序,该程序允许用户选择特定的费率类别(从一组
单选按钮),然后输入通话时间和分钟.将小时转换为分钟
为了获得费用,然后以两位十进制的文本字段形式显示呼叫的费用
点.提示:使用DecimalFormat类.
参见图Q1作为输出屏幕.您不需要编写HTML文件.

必须显示在
小数点后两位

-------------------------------------------------- -----------------
我的一半答案:
0.05
Create a Java program that allows the user to select a specific rate category (from a set of
radio buttons), and enter hours and minutes of the call. Convert the hours to minutes in
order to get the charges and then display the charges for the call as a text field in twodecimal
points. Hint: Use DecimalFormat class.
Refer Figure Q1 as the output screen. You are not required to write the HTML file.

Must be displayed in
two decimal points

-------------------------------------------------------------------
my half answer :
import java.awt.*;
import javax.swing.*;

public class PYQMAY2010 extends JFrame
{
	private JLabel lb1, lb2, lb3, lb4;
	private JTextField tf1, tf2, tf3;
	private JRadioButton rb1, rb2, rb3;

public static void main(String []arg)
{
	PYQMAY2010 l = new PYQMAY2010();

	l.setSize(400,300);
	l.setVisible(true);
	l.setTitle("Applet Viewer: LongDistanceCalls");
	l.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

	public PYQMAY2010()
	{
		lb1 = new JLabel("Enter hours of the call:");
		lb2 = new JLabel("Enter minutes of the call:");
		lb3 = new JLabel("Rate category:");
		lb4 = new JLabel("Charges for the call :RM");
		tf1 = new JTextField(20);
		tf2 = new JTextField(20);
		tf3 = new JTextField(10);
		rb1 = new JRadioButton("Daytime (6 am - 5.59 am)");
		rb2 = new JRadioButton("Evening (6 pm - 11.59 pm)");
		rb3 = new JRadioButton("Off-Peck (12am - 5.59 am)");

		JPanel p1 = new JPanel();
		p1.setLayout(new GridLayout (2,1));
		p1.add(lb1);
		p1.add(tf1);
		p1.add(lb2);
		p1.add(tf2);

		JPanel p2 = new JPanel();
		p2.setLayout(new GridLayout(4,0));
		p2.add(lb3);
		p2.add(rb1);
		p2.add(rb2);
		p2.add(rb3);

		JPanel p3 = new JPanel();
		p3.setLayout(new FlowLayout(FlowLayout.CENTER));
		p3.add(lb4);
		p3.add(tf3);

		setLayout(new BorderLayout());
		add(p1,BorderLayout.NORTH);
		add(p2,BorderLayout.CENTER);
		add(p3,BorderLayout.SOUTH);
	}
}


这篇关于我已经完成了一半的代码,但我不确定如何做其余的代码需要紧急帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆